.net - 无法加载 .Net 程序集

标签 .net windows vb.net dll .net-assembly

我正在尝试访问服务器上运行的 VB 程序中的 .Net 程序集。我收到经常提到的 Could not load file or assembly 错误。我已经浏览了大约 60 个不同的网页,但我所做的一切都没有解决它。

我将 dll 与我正在启动的可执行文件放在同一目录中。在 Appbase 中,它显示 file://?/c:,而在我看到的研究此问题的其他示例中,它们都有 file:///。我不知道这是否是问题所在。如果是这样,谁能告诉我如何解决它?我曾尝试搜索 file://?/,但据我所知,即使在 Google 和 Bing 中用问号括起来,它也会忽略所有特殊字符。

错误信息:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'cgiTest.modCurrentBalance' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.
File name: 'Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'
   at cgiTest.modCurrentBalance..cctor()

=== Pre-bind state information ===
LOG: User = WEBSERVER1\Administrator
LOG: DisplayName = Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
 (Fully-specified)
LOG: Appbase = file://?/c:/inetpub/intranet/
LOG: Initial PrivatePath = NULL
Calling assembly : cgiTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abaf442583423e6f.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Aspose.Cells, Version=7.4.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells.DLL.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells/Aspose.Cells.DLL.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells.EXE.
LOG: Attempting download of new URL file://?/c:/inetpub/intranet/Aspose.Cells/Aspose.Cells.EXE.

   --- End of inner exception stack trace ---
   at cgiTest.modCurrentBalance.GenerateReport()
   at cgiTest.Module1.ProcessFunction() in q:\visual studio 2010\Projects\cgiTest\cgiTest\Module1.vb:line 65
   at cgiTest.Module1.Main() in q:\visual studio 2010\Projects\cgiTest\cgiTest\Module1.vb:line 41

最佳答案

程序执行的用户是否有访问文件和文件夹的权限?可能是文件是从具有不同 ACL 的文件夹中移动的,而不是复制的,代码无法访问它。

最好的检查方法是获取 Process Monitor ,将其过滤器配置为仅显示对包含“Aspose.Cells”的路径的访问,并查看哪些进程尝试访问该文件,如果它们失败,如果失败 - 为什么。

关于.net - 无法加载 .Net 程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15535682/

相关文章:

PowerShell 5 中从未处理过的 C# 事件

c# - XDocument 到对象列表

c# - 为 Access mdb 文件创建 OdbcConnection 的 ConnectionString 是什么

windows - NSIS中止和错误级别

vb.net - Visual Studio/VB.Net 2008 IntelliSense 奇怪行为

c# - 从左到右编号坐标和拉绳

python - 在python中将unix纪元时间转换为windows纪元时间

php - mysqli 连接 - 如何创建用户名和密码? Windows 服务器2008

vb.net - 从 URL 检索图像尺寸

xml - 使用 LINQ 对属性进行 VB XML 查询