Click here to Skip to main content
13,346,397 members (121,265 online)
Rate this:
Please Sign up or sign in to vote.
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

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

           var reesult = Calculate_Retention_Time(file);
       public static double Calculate_Retention_Time(string sequence)
               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 8-Jan-13 16:40pm
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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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...
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
Of course. Under WoW64. If all executable modules of the process can be built to x86 target, it would solve the problem.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180111.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100