Adding dll created in VC++ in C# 2010 - c#

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

Related

accessing external .net DLL from own .net 4.6.1 c# interop DLL

I need to modify my existing DLL in c# to interface between PowerBuilder 2017 (PB) and an external DLL developed by vendor. external.DLL is using .net 4.6.1
PB Target <-> my.DLL <-> external.DLL
I have set my.DLL up to be COM Interop enabled (Make assembly COM-Visible + Register for COM interop) and have previously set this to work in PB IDE without 'external.DLL' just fine by applying following commands:
regasm my.DLL
gacutil my.DLL (this is used only so PowerBuilder can access the DLL from within it's IDE)
Now, I try and reference external.DLL through my.DLL from PowerBuilder IDE I receive an error -3 code (Object could not be created).
How am I best to setup and also distribute both DLL files?
I think my issue is in setting up the References within Visual Studio 2017.
The COM interop is needed between PB and my.DLL.
I tried to add a follow Debug option as this would be helpful, but cannot trigger it.
Thank you for help.
I managed to get my.DLL working inside PowerBuilder IDE by using regasm on the external.dll and adding it also into the GAC.
For deployment of the PowerBuilder Application I expect to apply regasm to both DLL's and place them in same distribution folder.

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?

Calling .net 4.0 built dll in Delphi 7

After searching and applying all solutions for below problem, are not working.
What I have done-
1. I created a .dll in C#, made its com visible ture.
2. I creadted the .tlb using regasm.
3. Created a Delphi 7 project where I imported this type library (.tlb) and calling the function of this dll.
4. All is running fine on my PC.
Now when I copied these all files (including .dll, even .dcu too) to another PC (.Net framework 4.5 installed) and tried to run the .exe, it gives me error "Class not registered", when I tried registering it with RegSvr32 then it shows error -"Entry point not found".
What else am I missing? Is there any other prerequisite to run Delphi 7 exe with dll on another PC?
To register a .net assembly you must use regasm and not regsvr32.
Making the entire assembly COM visible is probably a mistake. Do you really want to make all public type COM visible? It would be more usual to apply the ComVisible attribute to specific types.
You don't need to copy dcu files. These are used as intermediate files for the Delphi compiler. Assuming you aren't using runtime packages, just the executable, and the registered assembly should suffice.

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

How to see c++ and c# dll dependencies?

I have a python project that calls a c++ wrapper dll that calls a c# com interop dll.
In my computer, with all frameworks and programs installed, my project runs very well.
But in a computer that just got formatted it doesn't.
I allready installed c++ 2008 redistribute and the c++ part is working but when I call a function from it (that will call the c# correspondent one), it gives an error.
I want to know what are the dll dependencies from both c++ and c# dll's to see what is missing :)
Looks like you need Dependency Walker.
Dependency Walker (a.k.a. depends.exe) works for both native DLLs and managed DLLs.
It is included in some Visual Studio versions, and can also be downloaded here.

Categories