System.IO.FileLoadException - c#

I have got this error when using Enterprise Library 3.1 May 2007 version. We are developing a product and have a common lib directory beneath the Subversion Trunk directory
<>\Trunk\Lib\ into which we put all the third party DLLs. Inside this we have Microsoft\EnterpriseLibrary\v3.1 in which we have copied all the dlls from \Program Files\Microsoft Enterprise Library May2007\bin. Everything was working properly until one of the developers installed the source code on this machine. There were some dlls copied at the end of the source code installation and once that was done, he is not able to run the project anymore. He always gets this error
'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
What is the problem here? I thought that when the source code was installed it was just supposed to build everything and copy in the bin directory within the source code parent directory. Also we have copied the Dlls from Microsoft Enterprise Library May 2007\bin directory into our product development directory and references into our project with a copylocal flag set to true.
Can anyone help me out here
RK

I used to get that when I developed against the signed version of the dll and deployed where only the unsigned version was available.
Also, fuslogvw.exe. EVERY. TIME.

I assume the error lies in the developer having compiled the code against the unsigned source code compilation he has.
Make sure he adds the reference to the signed DLLs before compiling his code.
Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null
should be something like:
Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=fa03fef243232

maybe you should check the Assembly- and FileVersion of the dll. if they do not match this exception can occur.

Read here to get started with assembly loading debugging.
In short you need to check the Fusion log for more information.
For a "The located assembly's manifest
definition with name [yourAssembly]
does not match the assembly reference"
message (for hresult
FUSION_E_REF_DEF_MISMATCH,
0x80131040): The Fusion log will say
which part of the assembly reference
failed to match what was found. It
will be the assembly name, culture,
public key (or token) or version (if
the found assembly was
strongly-named).

Related

How to load locally build assemblies for debugging purposes?

I need to debug SharpDX to understand what is going on in my app - my project uses it via a reference from another NuGet package. Since the first package is referencing it with a PublicKeyToken even though I have built the same version of SharpDX and switched the SharpDX reference from NuGet to the local assemblies, my project wont build since it seems that it wants a signed version of SharpDX. The error message I am getting during the build is:
Error CS0012: The type 'TextLayout' is defined in an assembly that is not referenced. You must add a reference to assembly 'SharpDX.Direct2D1, Version=3.1.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'.
I have built this assembly with the same version (3.1.1.0) but I have not sign it (and I assume I cannot do this since the repo does not contain the key file).
Is there any way around this how I can make the NuGet package that references SharpDX load the locally built assemblies?
I found this and tried to turn off the strong name validation for that public key token, leave the references in tact (the project still references the SharpDX NuGet package) and replace the binaries and then run the application. It still fails at runtime with:
Message:Could not load file or assembly 'SharpDX.Direct2D1, Version=3.1.1.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
But this did not match the explicit error about the strong name given in the link. To verify the version I opened the build assembly with ildasm and the version is in tact:

System.Data.SqlXml Version 2 not installed on system

One of our build agent servers does not have System.Data.SqlXml Version=2.0.0.0 under C:\Windows\assembly but every other machine we have does. Unfortunately this causes nunit-summary.exe on that box to fail with:
EXEC Could not load file or assembly 'System.Data.SqlXml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. The system cannot find the file specified.
error MSB3073: The command ""../tools/nunit-summary.exe" artifacts/Test_*.xml" exited with code -1.
I tried installing MSXML 4 to no avail. I have not been able to figure out how to install version 2, any ideas?
Two possible solutions.
a) In the project, expand references to find the reference to the library. Go to properies and set Copy Local to be True. The .dll will then be included in the bin folder when the project is built.
b) Install SQLXML from Microsoft (this is different to MSXML which you tried). Details about the library (including the download link) are available at https://learn.microsoft.com/en-us/sql/relational-databases/sqlxml/what-s-new-in-sqlxml-4-0-sp1

Microsoft.Bcl.Async trying to load System.Threading.Tasks 1.5.11.0

I've added Microsoft.Bcl.Build/Microsoft.Bcl and Microsoft.Bcl.Async to some projects in my solution where I want to use async/await.
Everything works fine on my machine with .Net4.5 installed. However, when I start the application on a machine with only .Net4 installed, at some point, the application crashes with the following Exception:
Could not load file or assembly 'System.Threading.Tasks, Version=1.5.11.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)
Looking at the StackTrace, the exception seems to be generated in a third party library that we reference.
When I analyze the Microsoft.Threading.Tasks.dll provided by Microsoft.Bcl.Async, I see that it does reference System.Threading.Tasks Version 1.5.11.0, but version 2.6.10.0 is included in Microsoft.Bcl.
Am I doing something wrong?
I found the solution! It was actually very simple. I just had to copy and paste the binding redirects that nuget adds in the app.config files into the *.exe.config file. Then it just magically works. Easy fix.

Referenced assembly 'GenCode128.dll' is not a valid assembly

I am now dealing with a existing solution in VS2012.
Now I can execute it in debug mode but cannot trigger some of the function with the error
"Exceptions: System.Exception: Could not load file or assembly
'Interop.Score, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=5ce8a8a190705d24' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)"
After finding some of the suggestion, some of that suggest me to compile the solution in 32-bit (x86).
However, when I tried to rebuild with the target platform x86, another type of error occur and I even cannot run in debug mode, the error:
Referenced assembly 'GenCode128.dll' is not a valid assembly C#
P.S. GenCode128.dll is one of the error .dll, there is at least 2 of this kind of error.
I cannot search any successful way to solve this problem, appreciate for any help.
You can use a decompiler such as DotPeek (https://www.jetbrains.com/decompiler) to look inside your DLL and see if it is a valid .NET DLL -- and which version of .NET it is. It could be an x64-compiled assembly; in that case you cannot use it on a 32-bit system or from a 32-bit-compiled .NET assembly.
You can try installing it from NuGet.
I've created a NuGet package for GenCode128.dll here: https://www.nuget.org/packages/GenCode128/
Also the source can be found in GitHub: https://github.com/SourceCodeBackup/GenCode128

Error with EnterpriseLibrary 5.0.414.0 after opening the project with VS2012

I have a website written in VS2010 that uses a web reference to a service that uses EnterpriseLibrary 5.0.414.0.
When i worked with VS2010 everything was ok, but once i opened it with VS2012 RTM i started getting the following error (i get the same error when i open the project in VS2010 too)
Reference.svcmap: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
Please advice.
This can happen if you are missing the other enterprise library blocks needed by the mentioned assembly (and copy local true as well), which are:
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.Configuration.dll
Microsoft.Practices.Unity.dll
Microsoft.Practices.Unity.Interception.Configuration.dll
Microsoft.Practices.Unity.Interception.dll

Categories