1

I have a C# application and a C DLL both of which I wrote and both of which work on a few W7 (64-bit) and XP (32) machines I've tried it on. Today I installed the app/dll set on yet another machine (XP) and it crashes on the first call to the DLL. I've replaced the code in the DLL that gets called with return(0) and it still crashes. I've been using this app/dll set for a few days on a few machines without a glitch, but now I'm stumped 'cause it dies just accessing the DLL. Any ideas?

Added note since my original post: I've learned some things based on suggestions below... 1. the exception error message is "... side-by-side configuration is incorrect...". Googling seems to indicate that this is an issue related to the PC not having the correct (compatible) environment; however, note that this C# app has run on this PC just fine in the past (difference being that the DLL is now built with VS2008 rather than Cygwin/MinGW/GCC). 2. dependency walker tells me that the file IESHIMS.DLL cannot be found. I have no idea what this file is for, but apparently I need it.

Ed.
  • 928
  • 1
  • 10
  • 23
  • Is there any discernable difference between the failing machine and the other XP machines it works on? – Justin Morgan - On strike Apr 07 '11 at 20:40
  • Can you provide any error message information? If you're not executing any code in the C dll and it's crashing your application when you call it, it could be a problem with your Interop declaration (not explicitly stating a calling convention comes to mind). – Brandon Moretz Apr 07 '11 at 20:49
  • Well, I've successfully run this on a W7-64bit, and an XP-32bit machine, and the machine it crashes on happens to be W7-32bit. – Ed. Apr 07 '11 at 20:54
  • Not much useful info in the error message, it just says: " has stopped working" – Ed. Apr 07 '11 at 20:55
  • Is your app complied in Release? (it should be). Are the .NET and Windows service packs up to date? – Danny Varod Apr 07 '11 at 23:29

2 Answers2

1

Perhaps there is a missing dependency (dll) for the C dll (perhaps a C++ runtime?)? Can you run depends.exe : http://www.dependencywalker.com/ on the dll on the machine where your application crashes and see if there are any missing dependencies.

Could you also add exception handling around your first call to the C dll to catch and display any exceptions?

Andreas Paulsson
  • 7,745
  • 3
  • 25
  • 31
  • Ok thanks, I don't know why I didn't think of adding the try/catch wrapper, but that did give some more info. The exception message says the "...side-by-side configuration is incorrect...". – Ed. Apr 07 '11 at 21:20
  • Andreas, I ran dependency walker on my app and it tells me that it can't find the file IESHIMS.DLL. I have no idea what that DLL is. Note that I have run my C# app on this machine in the past, the difference is that the DLL is now built with VS2008, where the earlier version was built with MINGW. I *thought* I was cleaning it up by doing this! :-( – Ed. Apr 07 '11 at 22:32
1

The IESHIMS.DLL dependency appears for pretty much every file I open in dependency walker and its never been the source of any problems - you can almost certainly ignore that.

You should check to make sure that you have the correct version of the Visual C++ Redistributable, and you might also want to check this question - Side-by-side configuration error (Microsoft.VC80.CRT v8.0.50608.0) to make sure that this is not applicable to you.

Finally, you should make sure that your C# application targets a specific architecture (the one that the native dll was built against) rather than "Any CPU", as uisng "Any CPU" will mean that the program will run either as a 64 bit or 32 bit application depending on what machine you run it on, which will cause problems on 64 bit machines attemtping to load 32 bit native dlls.

If your app previously worked when compiled with a different runtime then it sounds like the Visual C++ runtime is simply not installed on that specific machine - you should never assume that it is, however on many machines it has already been installed by another application.

Update: Here is a link to the Microsoft Visual C++ 2008 Redistributable Package (x86).

Community
  • 1
  • 1
Justin
  • 84,773
  • 49
  • 224
  • 367
  • Kragen, I installed the microsoft visual C++ 2008 redistributable package and that cured it! Thanks much. – Ed. Apr 08 '11 at 17:39