solve the FileNotFoundException for the iTextSharp.dll on Windows Server 2008 R2

In a previous post I wrote a little function to convert HTML to PDF. I wanted to use this function on a server and start it with an event. The silly thing was that nothing happened. Later I figured out that the program crashed. It threw a  FileNotFoundException with the statement "PublicToken = 8354ae6d2174ddca", but the DLL was there and the reference was correct too.
Soooo I had to figure out why the error appeared.. It took a wohle day, but now I can present a solution. The architecture of a server stores assembleys in a Global Assembley Chache (GAC) to use them. So the server was looking for the assembley in the GAC and that is why the server was not able to find it. Right now the FileNotFoundException seems to be logic.
 Well.. after that step i was able to fix the problem. But adding a DLL to the GAC folder is more than drag and drop.
You need to configure an external Tool in Visual Studio 2010 or above (see this post).
The command will be: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe
Then enter the following argument :
/i "C:\iTextSharp.dll" 
I stored my iTextSharp.dll in C:\ to keep the path short. If your DLL is somewhere else you need to replace the path. The /i is a comand for installing (adding it to the GAC folder) it. If you need to uninstall (remove) it use /u.

Comments

Popular posts from this blog

How to support multiple languages in WPF