3

I have successfully added other .dll files to other C# project this way:

Right click Reference > Add Reference > Browse > Double click the .dll file

but Microsoft Visual Studio 2008 issues the following complaint:

A reference to ...\dll\FreeImage.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

I am using .NET Framework 3.5. I believe this is a 32bit dll (it downloaded with FreeImage3151Win32) so I changed the configuration of the project to x86.

What is the correct method to add FreeImage.dll to a C# project?

rene
  • 41,474
  • 78
  • 114
  • 152
jacknad
  • 13,483
  • 40
  • 124
  • 194
  • 2
    Is FreeImage.dll a .Net dll? Can you open it with ildasm, reflector or ilspy? – rene Dec 27 '11 at 19:19
  • I guess (since this library also works on Linux) that the DLL exposes a C API. If so, you need to use Interop to declare all the DLL exports, much as you would for the Win32 API. Or find someone who's done it already. – arx Dec 27 '11 at 19:22

5 Answers5

9

Use the wrapper provided in the download. There are C# samples in the \Wrapper\FreeImage.NET\cs\Samples directory.

keyboardP
  • 68,824
  • 13
  • 156
  • 205
1

The FreeImage.dll isn't a .Net dll. You need to write a wrapper in .Net which call the methods of the unmaged code. There is an example here but they also supply a .net wrapper in the binary distribution here

kev
  • 1,124
  • 2
  • 8
  • 12
0

In the current release (3.15.4), have to build the project in FreeImage\Wrapper\FreeImage.NET\cs to produce the DLL for C#. Then you find it in FreeImage\Wrapper\FreeImage.NET\cs\Library\bin\Release or Debug.

werner
  • 377
  • 2
  • 10
0

I've seen this before with files downloaded from the Internet that are "blocked" by the file system. Try going into the file's properties and clicking the "Unblock" button.

Jacob
  • 77,566
  • 24
  • 149
  • 228
-3

Save the file into the Bin folder and click Project > Add Reference > Browse > Double click the .dll file

C# sharp helps link

Bamara Coulibaly
  • 729
  • 1
  • 8
  • 7