简体   繁体   English

无法加载文件或程序集

[英]Could not load file or assembly itextsharp

I had build setup file from my winform application. 我已经从Winform应用程序中构建了安装文件。 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 然后我将其安装到另一台计算机上,一切正常,但是,当我单击SaveToPDF按钮时,该按钮将gridview保存为pdf文件

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. 无法加载文件或程序集itextsharp,版本= 4.1.6.15,文化=中性,公钥令牌= 8354ae6d2174ddca'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。

If I run application from visual studio everything works pretty good. 如果我从Visual Studio中运行应用程序,那么一切都会很好。 Therefore while building the setup File iTextSharp content may be lost or while installing from setup iTextSharp content lost. 因此,在构建安装文件时,iTextSharp内容可能会丢失,或者从安装iTextSharp内容进行安装时,可能会丢失。 I'm stuck with this problem and dont know how to fix. 我陷入这个问题,不知道如何解决。 Any help would be appreciated. 任何帮助,将不胜感激。

Right-click on iTextSharp and select Properties. 右键单击iTextSharp,然后选择“属性”。 Set "Copy Local" to True. 将“本地复制”设置为True。

Also I'd recommend using NuGet for package management. 另外,我建议使用NuGet进行程序包管理。 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: 如果设置“本地复制”不起作用或已将其设置为true,请删除引用,然后使用Package Manager控制台输入以下内容:

Install-Package iTextSharp

UPDATE: 更新:

I tried with the InstallShield 2015 trial. 我尝试了InstallShield 2015试用版。 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. 我尝试了一个基本的MSI项目,并在“应用程序文件”中使用iTextSharp程序集指出了该项目的主要输出。 When I built the project I got an error "-6213 - Internal Build Error" Apparently it's a known issue with the .NET projects. 生成项目时,出现错误“ -6213-内部生成错误”。这显然是.NET项目的已知问题。 Here is their article suggesting a workaround: https://flexeracommunity.force.com/customer/articles/en_US/ERRDOC/Q109089 这是他们的文章,提出了一种解决方法: 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. 但是,当我安装它时,仅部署了该应用程序的exe,而没有部署iTextSharp。 So this may be your case. 所以这可能是您的情况。 Do you recall disabling scanning dependencies? 您还记得禁用扫描依赖项吗?

I removed the Project Output and added the desired files manually. 我删除了Project Output并手动添加了所需的文件。 This time it gave another internal error but fixed it with their suggestion (replacing ISWIScanners.dll with a new one they provide and rebuild). 这次,它给出了另一个内部错误,但根据他们的建议进行了修复(将ISWIScanners.dll替换为他们提供并重建的新错误)。 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. 另外,您可以免费试用Wix( http://wixtoolset.org )-一个免费的开源安装程序。 I haven't used it myself but heard it on DotNetRocks podcast. 我自己没有使用过它,但是在DotNetRocks播客上听到了。 It's free so it might be worth a shot. 它是免费的,所以值得一试。

I hope this helps you. 我希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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