-
Notifications
You must be signed in to change notification settings - Fork 61
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
Visual Studio debugger assembly binding failure with EnvironmentConfigBuilder #129
Comments
In the ASP.Net scenario, we had to add a little bit of magic to make the ConfigurationBuilder feature work in the .Net framework. When a classic ASP.Net web application runs, it does not run in the default app domain. Instead, ASP.Net spins up a new app domain in the process and starts the application there. But in doing so, ASP.Net reads some configuration settings before spinning up the AppDomain so it can set certain flags on the domain it creates. The problem is, the default domain isn't using the bin path that the new domain will be using. So any config builders you have in your bin folder won't be found. If they're in the GAC or the normal search path for the hosting process they will be found. The decision was made to run the config builder if it could be found, but to continue gracefully if it couldn't be found - only in this ASP.Net pre-AppDomain loading peek at the web.config. So we swallow the not found exception and go on. If you're debugging with all first-chance exceptions enabled though, you'll hit a break in this case. :/ Really the only "workarounds" are to put the config builder dll's somewhere they can be found. |
Thank you, @StephenMolloy for the interesting explanation. Are there any Visual Studio Components, Workloads, or Extensions that you're aware of that would place any/some/all of the ConfigBuilders in "findable" locations? |
I had the same issue as this one and the solution I found to avoid the "loading configuration error" is to place the configBuilder in another assembly/dll, outside the aspnet project. |
@StephenMolloy
So I literally pointed to the |
ms come on fix this, ppl still need old stuff supported. |
Having re-read the description of this problem more closely, I am inclined to believe this is an IDE/tooling issue. It looks like VS is doing some independent processing of config for the app. This is probably better addressed with the VS team as it's not really the responsibility of nuget packages to unilaterally install themselves into directories that are not part of the application they are installed in. Feedback for VS2017 can be submitted as described here: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2017 However, I was not able to reproduce this error in my attempts on VS2017 or VS2019. There must be a missing step in there that triggers the IDE's independent processing of config that is left out of the repro description. If anybody has more complete repro steps to share, that would help in identifying the issue and whether there are any potential solutions. |
There's an assembly binding error that occurs when debugging my ASP.NET MVC application (.NET Framework 4.7.2) in Visual Studio 2017:
The following error occured [sic] while getting connection string information from the configuration file.
"An error occurred loading a configuration file: Could not load file or assembly 'Microsoft.Configuration.ConfigurationBuilders.Environment' or one of its dependencies. The system cannot find the file specified. (C:\...\Web.config line 20)"
My
web.config
file contains:My application does run as expected, and the configuration builder does behave as expected, but it is troublesome to debug in Visual Studio.
Using the Fusion Log Viewer, I tracked down this binding failure:
I was able to work-around by copying
Microsoft.Configuration.ConfigurationBuilders.Base.dll
andMicrosoft.Configuration.ConfigurationBuilders.Environment.dll
toC:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies
but this is unsatisfying.Is there a more-official solution?
The text was updated successfully, but these errors were encountered: