Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an idl file in my c++ project I want to create instance for coclass from this idl file in my second project which I have created in c#.

while creating that instance in c# project I get the exception at runtime.

I search the solution for the exception and mostly got that I should set the build platform to 32 bit.

What I have tried:

Quote:
I tried this and compile my both project in 32 bit but still got the same exception. Also when i compile both the project on 64 bit platform still got the same exception.

Also I have register my c++ dll using regsrv32 and its entry is added in registry under 64 bit.

I have created separate ATL project in C++ and tried to create the instance of a coclass in c#. This work for me in both 32 bit and 64 bit. For the ATL project I did not run any command to register dll I think visual studio did that for me. But for my existing non ATL project I am not able to instantiate c++ com class in c#.
Posted
Updated 12-Feb-18 6:15am
Comments
Richard Deeming 2-Feb-18 9:36am    
If the C++ dll is 64-bit, and is registered in the 64-bit registry, then the C# application will need to be set to 64-bit as well.

1 solution

Check whether the C+ app is in 32 or 64 bit mode. There are some setting to control it.

When working with 32 and 64 bit dlls the naming and path should be different, so system isnt mismatching the modules. Check that the needed side loaded dlls are correct and in place.

In the ATL projects the registration is a batch in the standard build process because the project wizard added it.

As stupid as it sounds: the error codes are the best hint what is wrong, the problem is to interpret them ;-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900