-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get assembly probing to work; not sure why. #73710
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I remember |
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsDescriptionWith earlier .NET Framework versions I was used to be able to configure additional paths for assembly probing by adding a Using the Resolving event from AssemblyLoadContext, I was able to load the assembly from code, but I was hoping for a config way. Reproduction StepsCreate a library project, add a class, build. Running the app as it is now will throw a FileNotFoundException because .NET doesn't know where to find the library assembly. Add Running the app will also throw the FileNotFoundException. Expected behaviorApp will find the assembly in (one of) the paths given in additionalProbingPaths and load it from there. Actual behaviorAssembly is not being found and a FileNotFoundException is thrown. Regression?No response Known WorkaroundsNo response Configuration{ Other informationNo response
|
@huoyaoyuan This document describes the additionalProbingPaths setting. |
The linked issue comment and the document seem to provide context for this issue |
.NET 6 intentionally doesn't have a way to add probing - the overall design is for the SDK to construct the entire app. Note that while The code approach is the best solution for this - you can write your code to read the location from a config file of some sort. |
Description
With earlier .NET Framework versions I was used to be able to configure additional paths for assembly probing by adding a
/configuration/runtime/assemblyBinding/probing node to my app.config file.
With .NET 6.0 this doesn't seem to work anymore.
After a lot of searching I found the additionalProbingPaths setting in .runtimeconfig..json, but this didn't work either.
Using the Resolving event from AssemblyLoadContext, I was able to load the assembly from code, but I was hoping for a config way.
Reproduction Steps
Create a library project, add a class, build.
Create an app project (I tried with a WinForms app), add an assembly reference to the library and set "Local copy" to false.
Instantiate a class from the library in the app.
Create a folder "Lib" in your app project, copy the library output to this folder and set "Copy to output" to Always.
Running the app as it is now will throw a FileNotFoundException because .NET doesn't know where to find the library assembly.
Add
"additionalProbingPaths": [
"Lib"
],
to the .runtimesettings.json
Running the app will also throw the FileNotFoundException.
Expected behavior
App will find the assembly in (one of) the paths given in additionalProbingPaths and load it from there.
Actual behavior
Assembly is not being found and a FileNotFoundException is thrown.
Regression?
No response
Known Workarounds
No response
Configuration
{
"runtimeOptions": {
"tfm": "net6.0",
"additionalProbingPaths": [
"Lib"
],
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "6.0.0"
}
]
}
}
Other information
No response
The text was updated successfully, but these errors were encountered: