I have a MFC dll which is used for scanning a document from scanner and i want to use that dll in web application for scan and uploading a document.I am not familier with MFC .Is it possible to refer th MFC dll?
I tried referring the dll but when i run it im getting error "External Component throws an exception".i would be very thankful if any1 could help me on this.
I am using the dll to call a function.Now the error im getting is
A call to PInvoke function 'App_Code.tvheafo_!Scancsharp+UnsafeNativeMethods::getpath' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters
of the PInvoke signature match the target unmanaged signature.
cathie16
Member
32 Points
16 Posts
MFC dll in c# web Application
Aug 06, 2011 02:15 PM|LINK
I have a MFC dll which is used for scanning a document from scanner and i want to use that dll in web application for scan and uploading a document.I am not familier with MFC .Is it possible to refer th MFC dll?
I tried referring the dll but when i run it im getting error "External Component throws an exception".i would be very thankful if any1 could help me on this.
ignatandrei
All-Star
134843 Points
21605 Posts
Moderator
MVP
Re: MFC dll in c# web Application
Aug 06, 2011 08:40 PM|LINK
Depends if the dll have a COM interface or exports a function.
If it is a COM, just reference that.
If not, you should use DLLIMport for the function of the dll. See http://msdn.microsoft.com/en-us/library/aa288468%28v=vs.71%29.aspx
cathie16
Member
32 Points
16 Posts
Re: MFC dll in c# web Application
Aug 07, 2011 07:03 AM|LINK
I am using the dll to call a function.Now the error im getting is
A call to PInvoke function 'App_Code.tvheafo_!Scancsharp+UnsafeNativeMethods::getpath' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
this is the code used for calling the function
this is the code im using to define the function in dll
[DllImport(_dllLocation)] [return: MarshalAs(UnmanagedType.LPStr)] public static extern string getpath([MarshalAs(UnmanagedType.LPStr)] string name);this is function definition in dll
extern "C" __declspec(dllexport) LPTSTR getpath(LPSTR aFilePath) { coding... }cathie16
Member
32 Points
16 Posts
Re: MFC dll in c# web Application
Aug 11, 2011 05:34 AM|LINK
I got the solution.
The call to MFC dll sholud like this:
[DllImport(_dllLocation, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.LPStr)] public static extern string getpath([MarshalAs(UnmanagedType.LPStr)] string name);