Problem in Calling native code from managed c++ dll.

Hey,

I wrote a managed c++ class library in viusal studio 2005. This managed c++ dll calls native C++ methods of an SDK. When I referenced this managed c++ library in a console applciation written in C# for testing every thing worked fine. Now I need to call the managed c++ class library through web service written in C#. When I call managed c++ methods from web service the code crashes on the line from where the native code starts( mean native class's objects are instatiated). Can any one help me in this regard. It's kinda hurry. Thanks.

[559 byte] By [HaroonSaeed] at [2007-12-22]
# 1
Please describe where your DLLs are stored on the web server.
JeremyWong at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2
The native lib file is on the local drive. The managed dll is referenced in the web service. So what files are you talking about?
HaroonSaeed at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3
Please

tell us what message you see when it crashes. The obvious reason

would be that the Windows loader can't find the native DLL. Put

it in a folder on your path (like c:\windows\system32).

nobugz at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 4

Actually the original Managed Dll code is written in MC++. It calls native C++ SDK code which consists of headers and dll. Now I want to call this managed dll through C# web service. When I enter the Managed Dll's function and debug it the exception occurs when I am initializing memory to some object of unmanaged class. The Exception message is "An external module has raised an exception." The Exception trace also dont show any good information. The code executes perfectly when I called it with a console application. I placed the native dll in System32 and on other paths but nothing is working out my way. So can any one help me now. I hope I make the situation clear. Thanks.

Haroon

HaroonSaeed at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 5
Sounds

like you're getting a general protection fault, an access violation

probably. Try making the debugger break on it with Debug + Exceptions,

check "Win32 Exceptions". If that doesn't get you anywhere, try using

the debug heap allocator.

nobugz at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 6

Are you sure, you have enabled the native debug engine? I'd suggest that you debug with the C++ debugger with both managed & native debugging enabled.

-hg

HolgerGrund at 2007-8-30 > top of Msdn Tech,Visual C++,Visual C++ Language...