When i run the portal it gives the following error:
Could not load file or assembly 'System.Runtime, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///D:/.....
LOG: Initial PrivatePath = ....\bin
Calling assembly : System.Runtime.CompilerServices.Unsafe, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: ....\web.config
LOG: Using host configuration file: ....\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.
LOG: Post-policy reference: System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: The same bind was seen before, and was failed with hr = 0x80131040.
System.Runtime is a Microsoft package that is part of the webapi project.
Observing the Pre-bind state information it shows that the system.runtime dll is being called from System.Runtime.CompilerServices.Unsafe dll. Also the following redirect is made:
LOG: Redirect found in application configuration file: 4.0.0.0
redirected to 4.1.1.0.
The System.Runtime Package version is 4.3.0 and generates dll version 4.1.1.0.
This is my first doubt. I thing dll version should be 4.3.0.0 but inspecting with ILSpy it shows that the Assembly version attribute is 4.1.1.0
Web config redirect is correct, it redirects the call to version 4.0.0.0 to
version 4.1.1.0 as show in the Pre-bind log
The odd thing is that System.Runtime doesn't show in the references of the project. If i add it manually it gets an yellow icon (fail).
What is wrong here? What more can i check?
Found out that the problem was caused by a version conflict and not by an incompatible version as i expected.
The follow build warning exposed the conflict. Just need to double click on the warning message to fix the binding session on the web conflict.
Warning Found conflicts between different versions of the same
dependent assembly. In Visual Studio, double-click this warning (or
select it and press Enter) to fix the conflicts; otherwise, add the
following binding redirects to the "runtime" node in the application
configuration file: ...
I am not sure if Visual studio will be able to detect all build conflicts,so the absence of this warning may still be caused by the same error.
Related
I've already been through this answer on S.O. but it really doesn't seem to solve my issue - this is not a complex multi-project web solution.. it's much smaller and doesn't really need binding redirects as there aren't multiple projects vying for the same DLL reference.
For the project in question: we own the source code, we have the Visual Studio Project files, the DLLs in question here are wholly owned and wholly known.. we have access to the history of the code in SVN.
In short, I wanted to upgrade a DLL that we once-upon-a-time would drop into another project, manually.. I want to turn it into a NuGet on our private feed. I've done this a hundred times.. no big deal.
The DLL is a fairly simple .NET 4 framework code and has no other dependencies
But when I 'nugetize' the project and then reference it in another project, it cannot be 'found' successfully at run time. I get this error when we go to invoke the class contained within it:
Could not load file or assembly 'MyCorp.DataAccessLayer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=e5ee1faf2523c727' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
If I go into debug mode, visual studio shows this in the FusionLog property of the error intellisense:
=== Pre-bind state information ===
LOG: DisplayName = MyCorp.DataAccessLayer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=e5ee1faf2523c727
(Fully-specified)
LOG: Appbase = file:///C:/MyCorpRepository/MyCorp.AttachmentManager/Trunk/MyCorp.AttachmentManager.Tests/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : MyCorp.DefaultAttachmentManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\MyCorpRepository\MyCorp.AttachmentManager\Trunk\MyCorp.AttachmentManager.Tests\bin\Debug\MyCorp.AttachmentManager.Tests.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: MyCorp.DataAccessLayer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=e5ee1faf2523c727
LOG: Attempting download of new URL file:///C:/MyCorpRepository/MyCorp.AttachmentManager/Trunk/MyCorp.AttachmentManager.Tests/bin/Debug/MyCorp.DataAccessLayer.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
What do I need to look at to pinpoint the problem?
I've created a .NET standard library 2.0 which uses Microsoft.Data.SqlClient Version=1.12.20106.1. I'm referring to this library in the console application (.NET Framework 4.7.2). While making call, I'm getting the error shown below, even though I've added an assembly reference. Can anyone help please?
Could not load file or assembly 'Microsoft.Data.SqlClient, Version=1.12.20106.1, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5' or one of its dependencies. The system cannot find the file specified.":"Microsoft.Data.SqlClient, Version=1.12.20106.1, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5"}
Chances are that in the full error you will see something like
The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
When I experience a similar problem and run a unit test in the debugger then I see this sort of thing in the unit test output Pre-bind state information
Pre-bind state information
LOG: DisplayName = Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5
(Fully-specified)
LOG: Appbase = file:///C:/Dev2/MyApp/UnitTests/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : MyApp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=c.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Dev2\myapp\UnitTests.dll.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 2.0.20168.4 redirected to 1.12.20106.1.
LOG: Post-policy reference: Microsoft.Data.SqlClient, Version=1.12.20106.1, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5
LOG: Attempting download of new URL file:///C:/Dev2/MyApp/UnitTests/bin/Debug/Microsoft.Data.SqlClient.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
The issue is an assembly binding issue the answer here may help. Don't worry that it mentions VB6 the actual issue is independent of that.
This answer is only useful if your netstandard2.0 library has referenced Microsoft.Data.SqlClient as a NuGet package and the referred assembly is not copied over on build.
You may have to use dotnet publish to have the Microsoft.Data.SqlClient assembly copied. It's something that I stumbled upon lately and that I had to fix using a custom resolver. You shouldn't use that resolver but you should check if publishing your application and library helps the issue.
I've updated my Visual Studio Code this morning, after doing update it restarted it self. I did not get any options(i.e. "Goto Definition", "Rename Symbol")when I right click on any variable, method, class name. After searching for a while I found that Opening View > Output might help me to know what's going on. and I found Omniserver is not running and below is the error which I got in Output window.
Starting OmniSharp server at 4/17/2019, 2:42:04 PM
Target: d:\projects\Division\Division.sln
OmniSharp server started.
Path: C:\Users\Unity3\.vscode\extensions\ms-vscode.csharp-1.19.0\.omnisharp\1.32.18\OmniSharp.exe
PID: 7508
System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1()
at OmniSharp.HostHelpers.Start(Func`1 action)
=== Pre-bind state information ===
LOG: DisplayName = netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
(Fully-specified)
LOG: Appbase = file:///C:/Users/Unity3/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Unity3\.vscode\extensions\ms-vscode.csharp-1.19.0\.omnisharp\1.32.18\OmniSharp.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Users/Unity3/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Users/Unity3/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/netstandard/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Users/Unity3/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/netstandard.EXE.
LOG: Attempting download of new URL file:///C:/Users/Unity3/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/netstandard/netstandard.EXE.
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).
I had the same problem with Omnisharp v1.19.0 after updating VSCode. I ended up resolving it by rolling back the C# extension to an earlier version that worked for me (1.18.0). Right click the extension and select Install Another Version... Hope this helps!
The rollback to 1.18.0 worked for me, but be sure to set the preference "extensions.autoUpdate" to false or it will just reinstall 1.19.0
It looks like that the depencencies of VSCode C# plugin were missing.
When you reinstall C# plugin, the dependencies will be re-downloaded. May solve this problem.
Latest OmniSharp requires .NET 4.7.2 to be installed, see https://github.com/OmniSharp/omnisharp-roslyn/blob/master/CHANGELOG.md#13214---2019-04-08
Disclaimer, this solution worked for Ubuntu Linux v20.04
I installed mono-devel from Here and everything worked.
Fellow developers,
I've encountered a problem in my dev environment.
I've created a project which uses EntityFramework and ASP.NET Identity, and then a few other projects like WCF service and WebForms site that reference the first one.
The projects compile and work fine, but when I try to use "Update-Database" in Package Manager Console to update my migration-enabled database i get:
System.Data.Entity.Core.MetadataException: Schema specified is not
valid. Errors: (0,0) : error 0004: Could not load file or assembly
'Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
The version of Microsoft.AspNet.Identity.EntityFramework I'm referencing in every project is 2.0.0.0 (I upgraded it at some point with NuGet). How to find out who is looking for the old version and fix that problem?
I've tried the following steps:
Manually checked the references for every project in Visual Studio. All of them had
correct version (2.0.0.0) and DLL path specified and "Specific
version" property set to "False".
Cleared the "Temporary ASP.NET Files" in my AppData and C:\Windows...
Of course cleared the entire solution (deleted bin & obj folders)
Manually checked every *.csproj file for invalid references
Reinstalled the packages with NuGet (Update-Package -includePrerelease -reinstall)
Included assembly binding redirection in every App.config/Web.config:
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNet.Identity.EntityFramework" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Got the Fusion Log:
*** Assembly Binder Log Entry (2014-04-18 # 01:10:23) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Developer/sharp/projects/ShadowServer/DataModel/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Developer\sharp\projects\ShadowServer\DataModel\tmp2BEF.tmp
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Developer/sharp/projects/ShadowServer/DataModel/bin/Debug/Microsoft.AspNet.Identity.EntityFramework.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Developer\sharp\projects\ShadowServer\DataModel\bin\Debug\Microsoft.AspNet.Identity.EntityFramework.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Sorry for my English in advance :)
In my case I was getting this below error:
Could not load file or assembly 'Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I realized that my main UI startup project had old versions of Microsoft.AspNet.Identity.EntityFramework by default... (whereas in the other datalayer project I had manually gotten the latest libraries) so just updated the main project also from NUGet.
I'm in dll hell here with a large project. I have a dll patch which I'm trying to put into the assembly such that I can overide the built dlls in the project. I'm adding the .dll to the StartProject and replacing the existing one, but I get the following error and I don't know why this is the case. I've tried changing the specific version to False and the runtime versions all look identical for each of the dll's. The only difference in properties between this dll and the others is the use of an option called SpecificVersion - but this is set to false anyway.
Failed processing: System.IO.FileLoadException: Could not load file or assembly
XXX.XXX.XXX, Version=X.X.X.X, Culture=neutral, PublicKeyTok
en=5353c9f66d4ed1ec' or one of its dependencies. The located assembly's manifest
definition does not match the assembly reference. (Exception from HRESULT: 0x80
131040)
File name: 'XXX.XXX.XXX, Version=X.X.X.X, Culture=neutral, P
ublicKeyToken=xxxxxxxxxxxxxxx'
at XXX.XXX.XXX.XXX.XXX.XX(.....)
I'm looking at the fuslogvw failure output for binding and I get the following. Sorry for Redacting again.
=== Pre-bind state information ===
LOG: User = X
LOG: DisplayName = DataObjects, Version=0.4.1060.0, Culture=neutral, PublicKeyToken=5353c9f66d4ed1ec
(Fully-specified)
LOG: Appbase = file://X/lib/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Program.exe
Calling assembly : Storage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: DataObjects, Version=0.4.1060.0, Culture=neutral, PublicKeyToken=5353c9f66d4ed1ec
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///X/DataObjects.DLL.
LOG: Assembly download was successful. Attempting setup of file: X\DataObjects.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: DataObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5353c9f66d4ed1ec
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
SpecificVersion only matters when you build your project. At runtime, the CLR insists on finding an exact match. In other words, the [AssemblyVersion] of the reference assembly that was used when the project was originally built must be an exact match with the [AssemblyVersion] it finds back at runtime. A mismatch is very dangerous, causing true DLL Hell when the program tries to execute code in the assembly that substantially changed from the code it was tested against.
So if you create a patch then you must be sure that the [AssemblyVersion] attribute as declared in the AssemblyInfo.cs source code file matches the original. Do make sure that you don't let it increment automatically, using [1.0.*] is pretty popular and will always cause this runtime error.
Your assembly is also strong-named, the PublicKeyToken value must match as well. Be sure to sign it with the same private key.
Using a <bindingRedirect> element in the app.exe.config file is a way to force the CLR to accept a version mismatch.
After edit: yes, there's clearly a gross mismatch in the assembly version. The app was built with DataObjects version 0.4.1060.0 but found version 1.0.0.0