Using COM dll in a C# Project - c#

I have all COM dll generated from a C++ library project. I want to use it in my C# project. I guess, I should import the xxxLib.dll file from the C++ library project, and import it to my C# project. But this xxxLib.dll is not generated in my C++ project. But I could see that xxx.dll and xxx.tlb are generated

You just register the dll with regsvr32.
Then add a reference, go to the COM tab, and choose your COM dll.

Related

Load tlb at runtime in C++

I have created a dll in C# which needs to be consumed by various C++ applications.
During installation of my product, I execute the regasm command to generate the .tlb file for my dll.
How can I load this tlb from my C++ application and call functions on it?

Visual Studio is missing reference to COM dll

I have a project on C#. Furthemore I have a library that is developed on C++ and successfully built. I need to use that library in my C# project. So I registered C++ dll in COM and this is successfully registered and I can see it in registry in noe HKEY_CLASSES_ROOT/Wow6432Node/CLSID.
When I add reference to that COM dll in my project it is missing and I can't see anything from that library.
What the problem can be? Is it possible that if COM dll has any dependency and it require to reference it in my project?

Using Registration-Free COM Interop with a C# .NET DLL without codebase/GAC?

I have a C# .NET DLL that is exposed through COM Interop for which I have generated a manifest file. The DLL is being consumed through an Excel VBAProject using CreateActCtx and CreateObject to create my objects.
Everything works fine, however... I need to call regasm MyProject.dll /codebase or register with GAC. Otherwise I get ActiveX component can't create object or error in dll errors.
Is it possible to use a .NET DLL without having to register the DLL at all? I was able to do this previously with a VB6-based DLL and a manifest file.

Adding dll created in VC++ in C# 2010

I have a dll created in VC++ and visual studio 2005 now i want to add same dll in my C# application and VS2010.
But whenever i tried it gives me erro
"a reference to "../name.dll"could not be added please make sure that the file is accessible and that it is a valid assembly or com component"
Seems like C++ dll is native dll (and not managed C++/CLI)
You need to look at P/Invoke.
Platform Invoke Tutorial
DLL Import

statically linking multiple VC++ libraries to a C++/CLI dll

So I have this C# project that requires the use of some functions from a vc++ library. This vc++ library is then dependent on other vc++ libraries.
So in order to get this working, I created a c++/cli dll project that wrapped the main vc++ library. In the project linker settings, I just added the target vc++ library in the input field, and this resolved linker errors. I then added a reference to the cli project to the c# project references.
Everything compiled fine, but when I ran the C# project, there was a File.IO.Exception saying that the cli dll couldn't be loaded. After some tinkering around, I found that this error was happening because the wrapped vc++ dll dependencies could not be loaded. So I copied the vc++ dll into the same folder as the c# exe. I also had to copy all of the other vc++ dlls that the initial dll depended on.
Having to keep track of all of the VC++ dlls is burdensome, so I'm wondering if it is possible to statically link all of the VC++ dlls into the C++/CLI dll, so I do not have to copy them into the same folder as the C# exe. I tried adding all of the vc++ dependencies to the linker input field but that didn't do anything.
Thanks,
Alex

Categories