Click here to Skip to main content
11,703,617 members (64,206 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ C#
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 15:40pm
Sergey Alexandrovich Kryukov at 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.

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.
Sergey Alexandrovich Kryukov at 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...
Christian Graus at 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 at 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.

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

  Print Answers RSS
0 Maciej Los 570
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 430
3 Andy Lanng 249
4 CPallini 195
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2015
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