The problem is that when you are using the LEADTOOLS functions in a class library, the Leadtools.Codecs.???.dlls do not get copied over to the main project's EXE folder. Visual Studio doesn't detect the Leadtools.Codecs.???.dll files as dependencies so it does not copy them to the main project's output folder. Because of this you will get either an "Invalid file format" exception or a "Feature not supported" exception. So what you have to do is add the Leadtools.Codecs.???.dll references to the main project.
Let's say your class library project is called 'MyClassLibrary', and your main application project is called 'MyApplication'.
Your MyClassLibrary references are:
- Leadtools.dll
- Leadtools.Codecs.dll
- Leadtools.Codecs.Bmp.dll
Your MyApplication references are:
- MyClassLibrary.dll
When you build your solution MyClassLibrary.dll, Leadtools.dll, and Leadtools.Codecs.dll will be copied to the MyApplication's output folder. The output folder for MyApplication will look like this:
- MyApplication.exe
- MyClassLibrary.dll
- Leadtools.dll
- Leadtools.Codecs.dll
When you run your application and you try to load a BMP file it will not find the Leadtools.Codecs.Bmp.dll, so you will get an "Invlaid file format" exception. To resolve this issue you have to add Leadtools.Codecs.Bmp.dll to your MyApplication project. This will make Visual Studio copy the Leadtools.Codecs.Bmp.dll to the output folder of MyApplication.
Your MyApplication references should now be:
- MyClassLibrary.dll
- Leadtools.Codecs.Bmp.dll
And the output folder for MyApplication will have:
- MyApplication.exe
- MyClassLibrary.dll
- Leadtools.dll
- Leadtools.Codecs.dll
- Leadtools.Codecs.Bmp.dll
Now if you run your application you will not get "Invalid file format" or "Feature not supported" exceptions.
This applies to all formats, not only BMP. So if you want to load JPEG, BMP, PNG, and PDF files you need to add all those codecs references to the MyApplication project. You can read the
Files To Be Included With Your Application article to see what DLLs you will need.
Edited by moderator Thursday, August 1, 2019 8:58:25 AM(UTC)
| Reason: Not specified