Wrapping a C# DLL with COM Interface to be Called by C++ in VS2015
Step 1 – Run Visual Studio 2015.
Step 2 – Create a ‘Class Library’ project in VS2015.
Step 3 – Right click project -> Properties -> Build -> Select ‘Register for COM Interop’
Step 4 – Create a class file in which you would put the COM interface and class.
Step 5 – Using the following namespace in your class file.
using System.Runtime.InteropServices;
Step 6 – Create an interface and set the following attribute.
[ComVisible(true)]
Step 7 – Generate GUID attribute for the interface using the ‘Generate GUID’ tool.
Step 8 – Add a new class which implements the interface just created. Add the 2 attributes below to the class.
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
Step 9 – Generate GUID for the class.
Step 10 – Implement the function in the class.
Step 11 – Set [ComVisible(true)] in AssemblyInfo.cs
Step 12 – Build the project. A tlb file and a dll file would be generated.
Step 13 – Open your C++ project.
Step 14 – Put the tlb file in the project folder. Add the import code like below. After building your C++ project, a tlh file would be generated.
import “xxx.tlb”
Step 15 – Don’t forget to use the namespace you created in the C# dll. Myself always forget this.
Step 16 – Adding the codes in your C++ project like below.
CoInitialize(NULL);
interfaceInCSharp p(__uuidof(classInCSharp));
_bstr_t pt = p->functionInCSharp( );
CoUninitialize();
Step 17 – Use REGASM.exe to register C# dll.
invicta 31290
although internet sites we backlink to beneath are considerably not associated to ours, we really feel they’re in fact worth a go by means of, so have a look
винтажные постеры
very few web-sites that occur to be in depth beneath, from our point of view are undoubtedly properly really worth checking out
Google
Always a huge fan of linking to bloggers that I adore but really don’t get quite a bit of link adore from.
Google
Here is a good Blog You might Uncover Fascinating that we encourage you to visit.
Hi there, I discovered your website by the use of Google even as looking for a similar topic, your site came up, it seems to be great. I have bookmarked it in my google bookmarks.
Excellent post. Keep posting such kind of information on your blog. Im really impressed by it.
Asking questions are truly nice thing if you are not understanding something entirely, except this paragraph offers nice understanding yet.
Thanks so much for the blog post.
Thanks for fantastic info I was looking for this info for my mission.
A big thank you for your article.
Like!! Thank you for publishing this awesome article.
I’ve recently started a blog, the info you provide on this web site has helped me greatly. Thanks for all of your time & work.
Thanks a bunch for sharing this with all of us you really know what you’re talking about! Bookmarked. Please also visit my web site =). We could have a link exchange arrangement between us!