Question

I am trying to upgrade a project from VS2005. It is a VB.NET project B that depends on a C# project that references a C++ dll, A.dll. I am getting an error saying 'Unable to find assembly A_class, Version 2.0.0.0, Culture=neutral, PublicKeyToken=null'. The targeted platform of the C++ project is 4.0 and since that project depends on others, I can't downgrade it. But I did set the platform for the VB.NET project to 4.0. What else does the Version 2.0.0.0 refer to ? I have tried to create a brand-new project and added the vb forms into it after I have built it successfully. The C++ dll is in the output directory, if the VB project doesn't find it there, it doesn't get to this point. During build. I either get no error (but forms don't load) or I get 2 errors (one for each form):

error MSB3103: Invalid Resx file. Could not load file or assembly 'A-class, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 136, position 5.

Please help me, give me a suggestion, I don't know where to look. thank you very much.

Was it helpful?

Solution

"An attempt was made to load a program with an incorrect format"

99% of the time this means you are trying to load a 32-bit assembly using 64-bit tools, or vice versa. The version number in the error message just means the version number of the assembly that it's trying to load; it has nothing to do with .NET version being targeted. In this case it appears that the resource compiler is what has issues.

Try configuring your solution to explicitly build x86 instead of Any CPU and see if that resolves your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top