Referenced assembly 'GenCode128.dll' is not a valid assembly - c#

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

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:

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.

`Could not load file or assembly 'Microsoft.Windows.Shell` , Prism - C#

I'm trying to run PRISM (MEF) example project, but get this error:
Managed Debugging Assistant 'BindingFailure' has detected a problem in
'Prism4MefDemo.vshost.exe'.
Additional information: The assembly with display name
'Microsoft.Windows.Shell' failed to load in the 'Load' binding context
of the AppDomain with ID 1. The cause of the failure was:
System.IO.FileLoadException: Could not load file or assembly
'Microsoft.Windows.Shell, Version=3.5.41019.1, 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)
I've tried to remove and manualy add reference to Microsoft.Windows.Shell but still nothing.
The version of this DLL is 3.0.1.0, and not 3.5.41019.1 as in the Exception.
This is the line with the Excecption:
protected override DependencyObject CreateShell()
{
return this.Container.GetExportedValue<ShellWindow>();
}
How can I fix it?
Thanks.
Finally I solved this issue by installing Multilingual App Toolkit from here and Add Reference to "Microsoft.Windows.Shell.dll" from the location "C:\Program Files (x86)\Multilingual App Toolkit" or copy the dll to your private assembly folder and refer it.
When you install Microsoft.Windows.Shell.dll from Nuget, it was installing v3.0.1, But the actual expected version was v3.5.41019.1. you ll get this new version from the above path.
Thanks
So after trying everything, I looked for others files in my computer (Microsoft.Windows.Shell.dll) and found newer version, as expected by the Exception (3.5.41019.1) in MicrosoftRibbon for WPF\V3.5 folder.
It is strang,because the latest version of the NuGet package is 3.0.1.
Thanks anyway.
Adding Microsoft.Windows.Shell.dll v3.5.41019.1 to your project references, would solve the problem.
We had this problem when using the Ribbon control.
The solution was remove the ribbon: prefix from the very start of the XAML and use the default ribbon control, not the one that utilizes a namespace.

Updating assembly causes error

I updated a single 3rd party assembly, and I am getting an error:
Could not load file or assembly 'Some.Assembly, Version=1.0.3.15922,
Culture=neutral, PublicKeyToken=62a6874124340d6e' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
When I updated this assembly, the version is now 1.0.3.23655.
Is it because of a strong named assembly that other dependent assemblies are complaining about?
It's the version. You either need to rebuild (assuming that the dependent assemblies are yours), or if you are positive that the new version is compatible, you can configure .net to use the newer assembly. Details here: http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx
Yes this is what it is complaining about.
Please look here and here to guide you in resolving your versioning issue. Is your assembly signed using strongname?
Hope this helps.

System.IO.FileLoadException

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).

Categories