View Single Post
Old Jul 14th, 2008, 12:02 PM   #1
islam.abdo
Newbie
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0 islam.abdo is on a distinguished road
Question Please Help.. "HRESULT: DllNotFoundException"!!

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!
islam.abdo is offline   Reply With Quote