|
Hi,
I want to make only one file as /clr supported instead of whole project. But if i do the same i'm getting compilation error as -
Command line error D8016: '/ZI' and '/clr' command-line options are incompatible
My intention is to invoke managed API from unmanaged code.
I googled but not good result i found till now.
So kindly guide me how to avoid above error or any substitute Project-setting i need to do .
If possible please suggest(sample code)if any for my requirement.
Thanks
|
|
|
|
|
There is no sample code for your problem. The message is quite clear you cannot mix managed and unmanaged code in the same project this way. You need to split it into two projects, one which is normal unmanaged C++ and one which is managed and uses the /clr option. Calling Managed Code from Unmanaged Code and vice-versa[^] is a CodeProject article that will help you.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi Richard,
I got error when i tried as below -
- I created a COM Dll. Then i made it as CLR supported (whole project). But requirement is to make only required file as CLR supported.
It can be possible.
Because i observed,one of our existing COM dll contains only one file as CLR supported. And there is know issue with that COM Dll.
I think there is some project-setting or in code, we need to do for achieving the same.
That i'm trying to find out by comparing my project with that existing COM DLL. Unfortunately i didn't get any new thing till now.
Hence if any area i'm skipping while comparing ,Kindly advice .
Or any other way to achieve the same ,please guide
|
|
|
|
|
You may need to create a mixed mode wrapper dll. Create a new CLR class library. Inside that create a new unmanaged class (without the ref keyword) containing static functions. Expose it to your COM dll with the usual unmanaged __declspec macro declaration. Add a Framework reference to the managed dll you want to use.
Make sure the wrapper cpp file uses clr (should be default for managed dll, but check via right-click on cpp file, Properties, C/C++, General, Common Language Runtime support).
You could try to set the same option for one of the cpp files in your COM dll, if it's built in one of the newer VS versions. But chances are it won't work that way because of the incompatibilities you initially mentioned.
|
|
|
|