View Full Version : Using Unmanaged .DLLs in a plugin
A Marchini
11-01-2007, 01:00 PM
I seemed to have trouble trying to embed calls to an unmanaged dll(specifically the one from FTDI). I am currently running under the assumption that the free version of VS2005 (express) is possibly unable to link this. I am thinking a missing library of some kind.
Perhaps I am just attempting to resolve it incorrectly at compile time (not explaining to the compiler properly).
So for any .Net gurus, what might my problem be here?
Tony M.
teberle
11-01-2007, 09:35 PM
You need to add the System.Runtime.InteropServices
And this is an example of how I invoked an unmanged dll
[DllImport("inpout32.dll", EntryPoint="Out32")]
public static extern void Output(int adress, int value);
Post me what you are looking to invoke and I can help.
A Marchini
11-02-2007, 09:37 AM
You need to add the System.Runtime.InteropServices
And this is an example of how I invoked an unmanged dll
[DllImport("inpout32.dll", EntryPoint="Out32")]
public static extern void Output(int adress, int value);
Post me what you are looking to invoke and I can help.
Thanks, I got that far, but when I attempted to compile the system didn't know what [DLLImport meant. Also I was unable to add System.Runtime.InteropServices to the references of the IDE. It just wasn't listed.
Interestingly it did work if I uses a managed DLL, which wrapped the other functions. Which is wierd, and basically shows my lack of understanding as to the linking at this level.
I'll post the code I attempted and the code that worked, when I get a chance.
Tony M.
flowblok
11-02-2007, 08:52 PM
It's called P/Invoke ing (Platform invoke), and I don't think you have to add a reference to it. I think it's in the main System reference, so you would just have to say "using System.Runtime.InteropServices;" at the top of your code (assuming C#).
Referencing a Managed DLL which calls unmanaged DLLs works because the Managed DLL has already been compiled into bytecode.
A Marchini
11-03-2007, 01:06 AM
It's called P/Invoke ing (Platform invoke), and I don't think you have to add a reference to it. I think it's in the main System reference, so you would just have to say "using System.Runtime.InteropServices;" at the top of your code (assuming C#).
Referencing a Managed DLL which calls unmanaged DLLs works because the Managed DLL has already been compiled into bytecode.
I guess I misspoke, it isn't a managed DLL and it certainly isn't .NET since my VC++ 6.0 compilier doesn't know anything about .NET bytecode.
It is a type of DLL that the .NET compiler can figure out the offsets directly....
I now have the IDMX module, and now I am trying to figure out why the code I wrote, which is virtually the same, doesn't work.
In the end , a solution will be found... Let get out there and program ... guys! ahaaaahaaha...
Tony M.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.