Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I recently had to reference a DLL in my C# application using Visual Studio 2010. It appears it was written in C++ and I ahve to check "use unsafe" It uses a simple method. The code is below. It runs fine on my 32 bit system but I get the error below when I run it on my 64 bit system. I tried everything in the configuration but it will not run. Any suggestings would be appreciated

C#
static void Main(string[] args)
       {
           string file = "STGFEWR"

           var reesult = Calculate_Retention_Time(file);
       }
       public static double Calculate_Retention_Time(string sequence)
       {
           unsafe
           {
               SSRCalc.Class1 c = new SSRCalc.Class1();
               char* p = (char*)System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(sequence).ToPointer();
               double hydrophobicity_factor = c.TSUM3((sbyte*)p);
               return hydrophobicity_factor;
           }
       }



Could not load file or assembly 'SSRCalc.dll' or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1)
Posted
Comments
Sergey Alexandrovich Kryukov 8-Jan-13 22:18pm    
You don't show how you use the native-code DLL. P/Invoke? Anyway, you cannot execute code compiled to different instruction-set architectures in one process, ever.
—SA

1 solution

You have to make your exe 32 bit. As it is, it's running as 64 bit, and can't co-exist with your DLL. Change the build settings to be 32 bit.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jan-13 22:20pm    
Not even two different 64-bit instruction-set architectures (x86-64 vs Itanium) can be executed in one process. However, the code should match the real CPU, in contrast to x86, which is compatible with all 64-bit machines, but on Windows it only works via WoW64...
—SA
Christian Graus 8-Jan-13 22:21pm    
A 64 bit processor will run 32 bit code. It won't run a 64 bit exe with a 32 bit dll. I've had to do the same thing
Sergey Alexandrovich Kryukov 8-Jan-13 22:33pm    
Of course. Under WoW64. If all executable modules of the process can be built to x86 target, it would solve the problem.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900