在输入方法之前找不到文件或它的依赖项之一 [英] Could not find file or or one of its dependencies thrown before method is entered
问题描述
我想使用 Framework 4.7.2 库中的 windows 窗体
I want to use a windows form that is in a Framework 4.7.2 library
我有以下堆栈;
Framework 4.72 XAF Winforms exe which references
Framework 4.7.2 library1 which references
Framework 4.7.2 library2 which references a a standard2.0 library
我在 Library2 中有以下代码
I have the following code in Library2
public static void ShowMessageBox()
{
MessageBox.Show("hi");
}
public static void ShowForm() // errors when this is called
{
var form = new Form1(); // debugger can not reach here
MessageBox.Show("hi2");
}
我可以调用 ShowMessageBox但是,如果我调用 ShowForm,我会立即收到 System.IO.FileNotFoundException 异常.永远不会到达实例化表单的行.
I can call ShowMessageBox However if I call ShowForm I get a System.IO.FileNotFoundException exception occurs immediately. The line that instantiates the form is never reached.
System.IO.FileNotFoundException: 'Could not load file or assembly 'MyLibrary,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=a3471ea16b9add4c'
or one of its dependencies. The system cannot find the file specified.'
推荐答案
当我注意到 library2 中的一些旧引用旁边显示了一些黄色三角形时,我能够克服即时错误.我删除了那些引用.
I was able to get past the immediate error when I noticed that there were some yellow triangles displaying beside some old references in library2. I deleted those references.
现在错误发生在方法中,并显示了丢失文件的名称.
Now the error occurs within the method and the name of the missing file is shown.
这篇关于在输入方法之前找不到文件或它的依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!