Hi Steve,
What I had as a problem once is name mangling. Be sure to export your
entries from the C++ library as follows.
extern "C"
{
/* your exports */
}
Other than that, you should have no problem using the DllImportAttribute. A
small sample that works for me :
[ DllImport( "my_lib.dll", EntryPoint = "my_exported_function" ) ]
public static extern int MyExportedFunction (
[ MarshalAs( UnmanagedType.LPStr ) ] string fileName,
[ MarshalAs( UnmanagedType.U4 ) ] uint timeoutMs
);
// ...
int i = MyExportedFunction( "file.xml", 10000 );
If you still have problems using the dll, you could post a code-fragment
illustrating the problem...
HTH,
Tom T.
"SteveK" wrote:
Thanks for the quick answer, Ming,
I have added my call to DllImport and when I build the project, VS.NET
crashes SUPER fast, if I comment out the DllImport line, it's fine.
Isn't that nice? ;(
-Steve
"Ming Chen" <qq******@yahoo.com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl... Hi, SteveK.
You can't reference to a unmanaged DLL. You can, however, use
DllImportAttribute to call a unmanaged function in a Dll. See
http://www.codeguru.com/Csharp/Cshar...cle.php/c4217/ for a
simple example.
On the other hand, if the DLL exposes C++ classes, you may have to
convert it into a COM module or build a wrapper with Managed C++.
Regards
Ming Chen
"SteveK" <as***@asdfasdfsd.com> wrote in message
news:eo*************@TK2MSFTNGP14.phx.gbl... Hi-
I know this is common topic, but I don't intend to ask you guys "how" but rather "Where can I find samples or tutorials that actually compile??" ;)
I have been attempting to educate myself on this topic for awhile and 3
attempts to download source code and compile have yielded nothing. My
most recent problem is "System.DllNotFound" exception. The DLL is located in
the same directory as my .cs code. I tried to add a reference but recieved an error that it wasn't a valid type.
I would just really like to see a working example of using an unmanaged
code in C#. Anyone know a good place to read more?
Thanks-
Steve