English 中文(简体)
How do I call a 32 bit C DLL from C# running on Windows Server 2003 64 bit edition?
原标题:

I know I can’t compile my C# code using the default ”Platform Target : Any CPU” build setting and call a 32 bit C DLL. But if I change this setting to ”Platform Target : x86” the C# code should run under a 32-bit context and call the C DLL under that 32 bit context right? Although it doesn’t seem to work.

Do I have to register the 32-bit C DLL with some special registry or something?

I am using Windows Server 2003 64 bit.

The error is:

Runtime Error!
[Path to dll]
R6034
An application has made an attempt to load the C runtime library incorrectly.
最佳回答

You are correct. If you re building with the platform set to x86, your 32bit DLL should work fine.

If it s not, here are some things to check:

  1. Make sure the DLL is discoverable. This usually means including it in the same folder as your application s EXE.
  2. Make sure all of the dependencies required by your DLL exist (and are discoverable) on the system. This often means installing the correct VC++ redistributable.
  3. If you re using a 32bit COM component, make sure to register the component on the system.

Edit: After seeing your comment, your issue is due to the DLL not having a proper manifest. If you embed a manifest in the DLL, it should be able to properly resolve the correct C runtime, and load it (provided the correct runtime is installed on the deployment machine.)

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签