AccessViolationException when importing a function from a DLL.

Thanks in advance - if perhaps I have come to the wrong place, just suggest where I might better find some advice on my problem. The problem I am facing is that the program I am dealing with, which works as an .exe and as compiled by VS2003, no longer works in VS2008. The program is an executable that does a reconstruction from image slices; the executable is in C#, and it calls on a function exported from a DLL that was written in C++. When I open, compile, and run the project in VS 2008, I am confronted with an "AccessViolationException" at the call of the imported function.

I have tried the following:

1. Recompile the DLL with the /clr option.

The original compile instructions for the dll read as follows: "

del *.dll *.exp *.lib *.obj *.pdb

cl /O2 /G7 /arch: SSE2 /LD (Outputs.cpp, a few other .cpp program names*) /link /EXPORT: OutputFunction

*for some reason, Outputs.cpp does not have a header file, which is why it was compiled on the command line - I think.

Several forums implied that the problem may be an inconsistency between the static CRT that those compile-time instructions access and the CLR, and that if I recompiled with the option /clr in place of /arch: SSE2 that might solve it. So I compiled with:

cl /O2 /clr /LD (Outputs.cpp, a few other .cpp program names) /link /EXPORT: OutputFunction

This resulted in a "Debug Error R6034: An application has made an attempt to load the C runtime library without a manifest." It goes on to suggest I look at the Microsoft Shared Side-by-Side Assemblies Topic in the documentation. I must admit that I feel my inexperience quite sharply hear - instead of spending many more hours wading through documentation, I would like to make sure that I am not going down an erroneous path. Intuition tells me that the less I do to the code - that used to work, and which I have not changed - the better.

Thus, my question: What do I do the DLL or C# program to resolve this AccessViolationException?

Let me know if I need to provide some more info.

Thanks again - Chris

IDE: VS 2008, C++ settings.
Operating System: Windows XP Professional Service Pack 2
Hardware: Dell Latitude D620. 76 GB memory, 1GB RAM. Processor is IntelCoreDuo T2300E

Do you need to rebuild your interop for the DLL?
To be honest, I don't know. I can look up the details on my own, but what is the general idea? Thanks, by the way!
When you are using a non-.NET DLL in a .NET application Visual Studio will generate an Interop for the project.

The best way to get a new interop is to delete the reference to the project from you solution. Then re-import it (removing the .Interop files for it if present). This should cause a new Interop to be built.
Topic archived. No new replies allowed.