[英]Could not load file or assembly 'RevitApi' version = 19.0.0.0,
I've been creating an add-in for the program 'Revit' for the past few weeks now. 过去几周以来,我一直在为程序“ Revit”创建一个加载项。 It all went fine, but all of a sudden, whenever I try to set the
DataSource
of my DataGridView
to my class getEntiteitenData
, I get the error : 一切都很好,但是突然之间,每当我尝试将
DataGridView
的DataSource
设置为类getEntiteitenData
,都会收到错误消息:
Error using the dropdown: Could not load file or assembly 'RevitAPI, Version=19.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
使用下拉菜单时出错:无法加载文件或程序集'RevitAPI,版本= 19.0.0.0,区域性=中性,PublicKeyToken =空'或其依赖项之一。 The system cannot find the file specified.
该系统找不到指定的文件。
I did not change the files location or anything, and the .dll
is loaded in all the classes. 我没有更改文件位置或其他任何内容,并且
.dll
已加载到所有类中。 Also, I have used this method on another DataGridView
and it worked fine. 另外,我在另一个
DataGridView
上使用了此方法,并且效果很好。 The only difference I can tell so far, is the one where it works, it is an Windows Form
, the other, where it doesn't work, it's an user control
到目前为止,我能告诉的唯一区别是,一个可以在其中运行,它是
Windows Form
,另一个,在不起作用,它是user control
The most annoying thing about this is, when it gives the error, it shuts down my visual studio. 最令人讨厌的是,当出现错误时,它将关闭我的视觉工作室。
Any help would be greatly appreciated! 任何帮助将不胜感激!
You can try this. 你可以试试看
Add this line to the main class of your application. 将此行添加到您的应用程序的主类。 This must be called before anything.
必须先调用它。
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
Add this code to you aplication. 将此代码添加到您的应用程序中。
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assemblyFullName;
System.Reflection.AssemblyName assemblyName;
assemblyName = new System.Reflection.AssemblyName(args.Name);
assemblyFullName = System.IO.Path.Combine(
System.IO.Path.Combine(
System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), <You folder>), assemblyName.Name + ".dll");
if (System.IO.File.Exists(assemblyFullName))
return System.Reflection.Assembly.LoadFile(assemblyFullName);
else
return null;
}
This will load only the assemblies in the folder of your application or the folder defined by you 这只会在您的应用程序文件夹或您定义的文件夹中加载程序集
For some reason the problem was only occuring when i'm binding the data from the designer window. 由于某些原因,仅当我从设计器窗口绑定数据时才出现问题。 I tried binding it by code, and this worked !
我尝试通过代码将其绑定,并且这样做有效!
After I added this to my Designer.Cs: 在将其添加到Designer.Cs之后:
private System.Windows.Forms.BindingSource getEntiteitenDataBindingSource3;
this.getEntiteitenDataBindingSource3 = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.getEntiteitenDataBindingSource3)).BeginInit();
this.entiteitenGrid.DataSource = this.getEntiteitenDataBindingSource3;
this.getEntiteitenDataBindingSource3.DataSource = typeof(getEntiteitenData);
((System.ComponentModel.ISupportInitialize)(this.getEntiteitenDataBindingSource3)).EndInit();
Everything seems to work now, and the Columns I wanted to bind are actual visual in the designer now. 现在一切似乎都可以正常工作,而我想绑定的列现在在设计器中是实际的视觉效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.