![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2008
Posts: 1
Rep Power: 0
![]() |
Hi all..
I'm using VS.NET2005.. I created dll from C code.. then I created a C# console application that uses that dll, I locate dll in bin/Debug folder. Then DllImport in C# code. An exception called "HRESULT: DllNotFoundException" was thrown.. I don't know why.. However the dll already exists! ======= Example of what I made: ------------------------ -C code: -------- #include"stdio.h" __declspec(dllexport) void println() { printf("I'm println() function!\n"); } ================================================== -C# code: --------- using System; using System.IO; using System.Runtime.InteropServices; namespace testexe { class Program { [DllImport("testdll.dll")] public static extern void println(); [STAThread] static void Main(string[] args) { Console.WriteLine("I'll call C function Now..\n"); if(File.Exists("testdll.dll")) { Console.WriteLine("Dll Exists\n"); } else { Console.WriteLine("Dll Doesn't Exist\n"); } println(); } } } ======= thnx in advance.. waiting for ur help! |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
Re: Please Help.. "HRESULT: DllNotFoundException"!!
hmm, not sure if this is it but worth a try before looking into deeper solutions. maybe try typing out the full path to the .dll in both the import as well as the if statement. I tried it your way and the if statement failed, i put the full path and the if statement succeeded. so maybe give that a go.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|