Finding an unmanaged dll API? - c#

I am writing in C#.
How can i find out which methods/functions I can use in an unmanaged dll that doesn't belong to windows?
Exmaple : I have some installed software on my computer, it has a dll, and i want to know what my options are as to creating code to connect to that software?

For native DLL's that you do not have a reference for you can use the dumpbin utility in the Visual Studio SDK to extract the list of exported functions in a DLL.
Dumpbin reference is here: http://msdn.microsoft.com/en-us/library/c1h23y6c(VS.71).aspx
And a CodeProject page giving some additional details on how to use dumpbin in conjunction with finding the correct P/Invoke signatures is here: http://www.codeproject.com/KB/mcpp/usingcppdll.aspx#Retrieve

PInvoke.net is great resource for .NET interop. They list not only the functions available in Windows native libraries, but also the signature you need to use in your .NET code.

use Depends.exe (which comes along with VS).
Depends would display all the exported function that can be invoked from Managed code using Pinvoke.

I read a blog about PInvoke Interop Assistant, which can deal with our own DLLs as well
http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120

I would just like to add that if it's a COM assembly, like a VB6 COM component, it can be browsed in the Object Explorer in Visual Studio and that's pretty nice because it breaks everything out for you quite nicely.

Related

MSVS Solution with mixed C++/C and C# in same assembly

I have followed this example on how to mix C# and C++ code in single assembly and all compiles fine. But all this is from the developer command prompt. I want to put all this in one Visual Studio solution and can't succeed. Does anybody know how to do that? (I am still very inexperienced with Visual Studio)
I have found several articles about this, but all give examples from the command prompt. This SO answer even recommends not doing this at all, not sure why?
Also, many of those articles talk about creating a managed DLL (using dllexport/dllimport, but I need to link the obj/lib files directly in the same C# assembly.
Note: The reason I need to do this, is to add a licensing static library to my C# desktop application project. The library is written in C/C++ and is already used in my back-end, I would like to use the same logic for the front-end. Loading the library as a DLL would defeat the purpose since anybody could just change it for a fake one. Therefore linking it in the same assembly is essential.

What happened to the VB6 APIViewer?

I am trying to get knowledge of some of the WinAPI's in vb.net, but can't find the tool that used to exist for vb6, API Viewer.
Does VS2015 happen to come with something easier?
Is there a similar way of importing WinAPI code from a tool into vb.net?
It appears that VS2015 does not include a tool for browsing the Win32 API.
I was able to find through the assistance of some helpful comments above, a website known as PInvoke.net. However, this is outdated.
I did find references to PInvoke Interop Assistant, which is exactly what I was looking for.

How to build AIR Native Extension for Windows with C#?

I recently developed native extensions for mobile projects on Adobe AIR (Android and iOS).
I want to port these ANEs for desktop projects on Windows and OSX. The OSX part is not a problem because it uses the same mechanisms as for iOS. The problem is essentially on the Windows side.
Adobe AIR offers bridges to write the native part in C / C ++, I prefer to use C# to simplify the task and access more simply .NET libraries.
Has anyone ever heard of experiments or viable projects to code a native Adobe AIR extension with C#?
I have not found a complete solution to achieve this:
Create a DLL in C # including access to FlashRuntimeExtensions.h (C Header file)
Be able to use .NET libraries from this unique DLL
Produce only one DLL file
Do not use the flash.desktop.NativeProcess library
Thank you for your help or a different point of view on these issues.
According to Extending AIR, you just need access to any function on your DLL regardless what native method you used to create it.
This means that you still need to use a C++ project to link AIR to your native library but the main code can be done on C#. So you export your main code/logic into a DLL from C# and then use the C++ bridge project to Link both DLL and flash.
This link could also be useful : Windows ANE - tutorial introduction
A developer sent me this link to TUARUA's FreSharp GitHub page.
It corresponds exactly to the subject of my question. I share it so that everyone can see how to create an ANE (AIR Native Extension) from C# under Windows.
So I will be able to resume my development and port my libraries for desktop computers.
Thanks to everyone.

Quantlib 64-bit for C#?

Just discovered Quantlib and am evaluating it for use. I am not a C++ developer, and no one on staff where I work really has deep experience with it, so I am pretty much following the instructions by rote found here:
http://quantlib.org/install/vc10.shtml
The next step will be to convert to C# using SWIG (based on instructions found here: Compiling Quantlib via SWIG for C#).
My question is, when I have completed all of the steps listed in both posts, will the result be a library that can only be compiled as 32-bit? The Boost download seems to indicate that it is 32-bit only.
Is compiling as a 64-bit application possible and/or are 64-bit binaries available anywhere (Windows platform) and/or are alternative wrapper libraries (like QLNet) a good alternative?
I'm a regular user of QuantLib. Why would you convert QuantLib to C#??? There's QLNet, which is a direct port of the library in C#. Regarding about 64 bits, you just need to compile the source yourself.

Unable to load dll error

i am working project in c# Visual studio 2009,i am using c++ dll in my project and also i call that dll through my function . In my system the project run successfully.but in other system not in single system more than system i checked it shows exception like unable to load dll. i am check that dll in dependency walker it shows msvcr71.dll is missing.how i get this.?i need better solution for this
The problem is that your native C++ DLL depends on the library msvcr71.dll. This is not part of the standard windows installed hence you must take some action to get it onto the target machine.
The simplest way to do this is to just copy the DLL around with your application. The following KB article covers this.
Documentation on msvcr71.dll
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.71).aspx
You're probably missing something in your installation of the SDK (or Visual Studio). I would recommend a Repair or Reinstall.
look on msdn for info about redistributables - this tell you what you need to install on a non dev box to make things work
This is not programming related. You are missing a dll file on your target system. Download and put in "windows/System32" and it should run.

Categories