简体   繁体   中英

Could not load file or assembly itextsharp

I had build setup file from my winform application. Then I installed it to my other computer, everything was working normally however when I clicked the SaveToPDF button which saves the gridview to pdf file

I encountered with this error :

Could not load file or assembly itextsharp, Version = 4.1.6.15 , Culture=neutral, PublicKey Token=8354ae6d2174ddca' or one of its dependencies. The system cannot find the file specified.

If I run application from visual studio everything works pretty good. Therefore while building the setup File iTextSharp content may be lost or while installing from setup iTextSharp content lost. I'm stuck with this problem and dont know how to fix. Any help would be appreciated.

Right-click on iTextSharp and select Properties. Set "Copy Local" to True.

Also I'd recommend using NuGet for package management. If setting Copy Local doesn't work or if it's already set to true, remove the reference and using Package Manager Console enter this:

Install-Package iTextSharp

UPDATE:

I tried with the InstallShield 2015 trial. Here's my experience. I'm guessing it's pertinent to your problem:

I tried a Basic MSI project and in Application File I pointed the primary output of the project using iTextSharp assembly. When I built the project I got an error "-6213 - Internal Build Error" Apparently it's a known issue with the .NET projects. Here is their article suggesting a workaround: https://flexeracommunity.force.com/customer/articles/en_US/ERRDOC/Q109089

The suggestion is turning off Dependency Scanning at build. I did that and the project compiled fine. But when I installed it only the exe for the application was deployed and iTextSharp wasn't. So this may be your case. Do you recall disabling scanning dependencies?

I removed the Project Output and added the desired files manually. This time it gave another internal error but fixed it with their suggestion (replacing ISWIScanners.dll with a new one they provide and rebuild). This time I could get all the files I wanted deployed but of course it's not ideal.

I'd suggest adding the files manually and applying the workaround. Alternatively, you can give Wix ( http://wixtoolset.org ) a go - a free and open-source installer. I haven't used it myself but heard it on DotNetRocks podcast. It's free so it might be worth a shot.

I hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM