Skip to content

Visual Studio debugger assembly binding failure with EnvironmentConfigBuilder #129

@turbodrubin

Description

@turbodrubin

There's an assembly binding error that occurs when debugging my ASP.NET MVC application (.NET Framework 4.7.2) in Visual Studio 2017:

image

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:

<configBuilders>
  <builders>
    <add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </builders>
</configBuilders>

<connectionStrings configBuilders="Environment">
  <add name="PrimaryDatabase" connectionString="" />
</connectionStrings>

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:

*** Assembly Binder Log Entry  (5/13/2020 @ 3:17:00 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Configuration.ConfigurationBuilders.Environment
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.Configuration.ConfigurationBuilders.Environment | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\DavidRubin\AppData\Local\Microsoft\VisualStudio\15.0_073ea14d\devenv.exe.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PublicAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PublicAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PublicAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PublicAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.Configuration.ConfigurationBuilders.Environment/Microsoft.Configuration.ConfigurationBuilders.Environment.EXE.
LOG: All probing URLs attempted and failed.

I was able to work-around by copying Microsoft.Configuration.ConfigurationBuilders.Base.dll and Microsoft.Configuration.ConfigurationBuilders.Environment.dll to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies but this is unsatisfying.

Is there a more-official solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions