Click to See Complete Forum and Search --> : "CFile.Open" in Native MFC dll is not executed when managed C++ wrapper calls it


Madhuchhanda
December 14th, 2006, 09:13 PM
I have a native MFC dll which I need to access from the C# application.

I have written a managed C++ wrapper for this dll.My wrapper is a class library project.

The native dll(MFC dll) basically opens a MFC CArchive serialized file and deserializes it.
My c# app needs to access the data in this MFC CArchive.
I pass the filename as parameter to the native Dll member function which should open it and deserialize it.

However,when ever I try to call this function from the C# app -> managed c++ wrapper,the "CFile.Open' fails.On the other hand,the same file is successfully opened when other MFC apps call this native dll.

I have checked if the filename(parameter for the Load function in the native dll) is correctly received in the native dll and it is correct.

Any suggestions/pointers on what the problem might be would be really appreciated.

Thanks

TheCPUWizard
December 14th, 2006, 09:25 PM
CFile.Open should be returning an error code to indicate why it is failing......

Madhuchhanda
December 15th, 2006, 12:54 PM
Thanks!!

How do I catch the error?

I dont really want to modify the MFC dll as its a very big legacy project which has been there for a long time.