简体   繁体   English

奇怪的错误:System.IO.FileNotFoundException:无法加载文件或程序集

[英]Weird Error: System.IO.FileNotFoundException: Could not load file or assembly

I have 2 projects, 我有两个项目

The first project C# project where I have a blank form(new project). 我有空白表格的第一个项目C#项目(新项目)。 I am compiling this form as a dll so I can reference the form. 我将此表格编译为dll,因此可以引用该表格。

The VB project is an ExcelDNA project which consists of a custom task pane with a button to open the form,the task pane works fine. VB项目是一个ExcelDNA项目,由一个自定义任务窗格和一个用于打开表单的按钮组成,该任务窗格可以正常工作。 However, I get the following error when clicking the Button: 但是,单击按钮时出现以下错误:

System.IO.FileNotFoundException: Could not load file or assembly 

I can get this to work by creating a UserControl in the VB project, and then accessing it via the Button, however I have the form written in C# already and do not want to convert it to VB. 我可以通过在VB项目中创建UserControl,然后通过Button访问它来使它起作用,但是我已经用C#编写了表单,并且不想将其转换为VB。

There is no need to convert the project to VB.NET. 无需将项目转换为VB.NET。 This error is because the .net runtime cannot find the assembly (dll or exe that contains your first form). 该错误是因为.net运行时找不到程序集(包含您的第一个窗体的dll或exe)。 In Visual Studio, open the Solution Explorer window and expand the References node. 在Visual Studio中,打开“ Solution Explorer窗口,然后展开“ References节点。 Right-click the reference to your first assembly and click Properties . 右键单击对第一个装配的引用,然后单击Properties In the properties window change the Copy Local as True . 在属性窗口中, Copy Local更改为True

This way Visual Studio will copy the assembly to the output folder of the project ('bin\\Debug' or 'bin\\Release'). 这样,Visual Studio会将程序集复制到项目的输出文件夹(“ bin \\ Debug”或“ bin \\ Release”)。

因此,解决方案是确保将窗体Dll复制到Excel加载项所在的目录中。

暂无
暂无

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

相关问题 无法加载文件或程序集System.IO.FileNotFoundException - Could not load file or assembly System.IO.FileNotFoundException System.IO.FileNotFoundException:无法加载文件或程序集 - System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: '无法加载文件或程序集 - System.IO.FileNotFoundException: 'Could not load file or assembly System.IO.FileNotFoundException: 无法加载文件或程序集 C# - System.IO.FileNotFoundException: Could not load file or assembly C# 无法加载程序集>> System.IO.FileNotFoundException:无法加载文件或程序集'System.Core, - Unable to Load assembly>>System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, 错误详细信息:System.IO.FileNotFoundException:无法加载文件或程序集“System.Runtime,版本=4.2.0.0,Culture=neutralin JetBrains dotCover - Error details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutralin JetBrains dotCover System.IO.FileNotFoundException:无法加载文件或程序集“程序集名称”或其依赖项之一 - System.IO.FileNotFoundException: Could not load file or assembly 'name of assembly' or one of its dependencies 发布版本抛出“ System.IO.FileNotFoundException:无法加载文件或程序集”以查找XmlSerializers程序集 - Release build throws “System.IO.FileNotFoundException: Could not load file or assembly” looking for XmlSerializers assembly System.IO.FileNotFoundException:无法加载文件或程序集。 系统找不到文件SharpSvn.dll - System.IO.FileNotFoundException: Could not load file or assembly. The system cannot find the file SharpSvn.dll System.IO.FileNotFoundException:无法加载文件或程序集System.Xml.Linq - System.IO.FileNotFoundException: Could not load file or assembly System.Xml.Linq
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM