Friday, May 11, 2012 12:20 PM
I'm using CWinFormsView to use a .Net control in an MFC application.
This works OK.
I have some application specific initialization, so I made a subclass of CWinFormsView with the same parameters in the constructor:
This works when this class is in the same dll as it is used in.
I want to move this code to a common dll, so that it can be used from different dlls in the application.
Then the problems start. I get the following error message:
__declspec(dllexport) cannot be applied to a function with the __clrcall calling convention
How can I then make this class visible to other dlls?
It must be possible, I'm only trying to do what Microsoft already does itself, export a native class with a managed parameter in the constructor.
Has anybody any ideas on how to do that?
Monday, May 14, 2012 8:59 AMModerator
According to your description, I think you receive Compiler Error C3395. I am sorry to say that you cannot use dllexport on any method that includes a CLR type in its signature. The reason is that dllexport is a purely native construct and there is no way to support passing a CLR type, like System::Type and System::String, through the DLL boundary.
To fix this issue, please try the following recommended methods:
1->Don't use managed parameters or change it to a managed class.
2->Try to use this as a static library instead of a dynamic library.
By the way, you can refer to the following links if you want to know more information about this error:
I hope this reply is helpful to you. If you have any questions, please feel free to let me know.
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Helen ZhaoModerator Thursday, May 17, 2012 9:05 AM