简体   繁体   English

无法加载文件或程序集'RevitApi'版本= 19.0.0.0,

[英]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 : 一切都很好,但是突然之间,每当我尝试将DataGridViewDataSource设置为类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.

相关问题 无法加载文件或程序集 &#39;RestSharp,版本 = 105.2.3.0 - Could not load file or assembly 'RestSharp, Version=105.2.3.0 无法加载文件或程序集&#39;WebGrease,Version = 1.5.1.25624 - Could not load file or assembly 'WebGrease, Version=1.5.1.25624 无法加载文件或程序集 &#39;EntityFramework,版本 = 6.0.0.0 - Could not load file or assembly 'EntityFramework, Version=6.0.0.0 无法加载文件或程序集系统2.0.0版 - Could not load file or assembly System, Version 2.0.0 无法加载文件或程序集“Office,版本 = 15.0.0.0” - Could not load file or assembly 'Office, Version=15.0.0.0' 无法加载文件或程序集&#39;PayPalAdaptivePaymentsSDK,版本= 2.12.117.0 - Could not load file or assembly 'PayPalAdaptivePaymentsSDK, Version=2.12.117.0 无法加载文件或程序集&#39;AjaxMin,版本= 4.97.4951.28478, - Could not load file or assembly 'AjaxMin, Version=4.97.4951.28478, 无法加载文件或程序集 'MSHTML,版本 = 4.0.0.0, - Could not load file or assembly 'MSHTML, Version=4.0.0.0, 无法加载文件或程序集 &#39;EntityFramework,版本 = 6.0.0.0, - Could not load file or assembly 'EntityFramework, Version=6.0.0.0, 无法加载文件或程序集 &#39;Ninject 版本 4.0.0.0 - Could not load file or assembly 'Ninject version 4.0.0.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM