简体   繁体   English

无法加载文件或程序集'XXX,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一

[英]Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies

I have been trying to debug this Error: 我一直在尝试调试此错误:

System.IO.FileNotFoundException: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. System.IO.FileNotFoundException:无法加载文件或程序集'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。 File name: 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 文件名:'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'

I see a lot of solutions out there and try them all. 我看到了很多解决方案,并尝试了所有解决方案。

I am looking at Fusion Viewer and I am getting the following message: 我正在查看Fusion Viewer,并且收到以下消息:

LOG: This bind starts in default load context. 日志:此绑定在默认的加载上下文中启动。 LOG: Using application configuration file: I:\\Projects\\ACE Explorer\\AceV_1Explorer\\AceExplorer\\AceExplorer\\bin\\Debug\\AceExplorer.exe.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config. 日志:使用应用程序配置文件:I:\\ Projects \\ ACE Explorer \\ AceV_1Explorer \\ AceExplorer \\ AceExplorer \\ bin \\ Debug \\ AceExplorer.exe.config日志:使用主机配置文件:日志:使用来自C:\\ Windows \\ Microsoft的计算机配置文件.NET \\ Framework64 \\ v4.0.30319 \\ config \\ machine.config。 LOG: Post-policy reference: ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null LOG: GAC Lookup was unsuccessful. 日志:政策后参考:ClassLibrary1,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空日志:GAC查找失败。 LOG: Attempting download of new URL file:///I:/Projects/ACE Explorer/AceV_1Explorer/AceExplorer/AceExplorer/bin/Debug/ClassLibrary1.DLL. 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.DLL。 LOG: Attempting download of new URL file:///I:/Projects/ACE Explorer/AceV_1Explorer/AceExplorer/AceExplorer/bin/Debug/ClassLibrary1/ClassLibrary1.DLL. 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.DLL。 LOG: Attempting download of new URL file:///I:/Projects/ACE Explorer/AceV_1Explorer/AceExplorer/AceExplorer/bin/Debug/ClassLibrary1.EXE. 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.EXE。 LOG: Attempting download of new URL file:///I:/Projects/ACE Explorer/AceV_1Explorer/AceExplorer/AceExplorer/bin/Debug/ClassLibrary1/ClassLibrary1.EXE. 日志:尝试下载新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.EXE。 LOG: All probing URLs attempted and failed. 日志:所有探测URL尝试失败。

I see the file in the directory and the Target framework is 4.0 for all using x86 我在目录中看到该文件,并且使用x86的目标框架均为4.0

Any ideas of finding out what is broken 找出损坏的任何想法

Updated Sorry for the confusion. 抱歉,已更新 In the log it was PublicKeyToken=null. 在日志中是PublicKeyToken = null。 I was trying everything. 我正在尝试一切。

UPDATE I added some code in the main program that will resolve assemblies using the ResolveEventHandler. UPDATE我在主程序中添加了一些代码,这些代码将使用ResolveEventHandler解析程序集。 It didn't work at first. 起初它没有用。 But when I had the program load those external assemblies (LoadReferences()) in the start of the program it do work. 但是,当我让程序在程序开始时加载那些外部程序集(LoadReferences())时,它确实可以工作。 Weird since the path was exactly the same when I load them in the beginning LoadReferences() and then when the method enters a reference to a custom assemble which triggers the CurrentDomain_AssemblyResolve. 奇怪的是,当我在开始的LoadReferences()中加载它们,然后当该方法输入对触发CurrentDomain_AssemblyResolve的自定义程序集的引用时,该路径是完全相同的。 The blank path resolves to the assemblypath. 空白路径解析为Assemblypath。 As you can see, in the LoadReferences(), I am adding EntityFramework which will cause the same issue, even though I am using Nuget. 如您所见,在LoadReferences()中,我添加了EntityFramework,即使我使用的是Nuget,它也会引起相同的问题。

In Main() I added: 在Main()中,我添加了:

AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
LoadReferences();



private static void LoadReferences()
        {
            Assembly  objExecutingAssemblies;
            objExecutingAssemblies = Assembly.GetExecutingAssembly();
            AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();
            Assembly asm;
            foreach (AssemblyName strAssmbName in arrReferencedAssmbNames)
            {
                if (strAssmbName.FullName.ToLower().Contains("[company].") || strAssmbName.FullName.ToLower().Contains("entityframework"))
                    asm = Assembly.LoadFrom(Path.Combine("", strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(","))+ ".dll"));


            }
            // these were also posing an issue
            asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.dll"));
            asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.SqlServer.dll"));


        }
        static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            string assembliesDir = "";
            try
            {
                string dll = (args.Name.IndexOf(",") < 0 ? args.Name + ".dll" : args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll");
                Assembly asm = Assembly.LoadFrom(Path.Combine(assembliesDir, dll));
                return asm;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return null;
        }

Also. 也。 Not sure if this makes a difference but it is a clickonce with full trust. 不知道这是否有所作为,但这是一次完全信任的单击。

Also our desktops are pretty locked down. 此外,我们的台式机已被锁定。

Also platform is set to x86 for all projects. 此外,所有项目的平台都设置为x86。

file:///I:/Projects/ACE Explorer/.../bin/Debug/ClassLibrary1.DLL. 文件:/// I:/ Projects / ACE Explorer /.../ bin / Debug / ClassLibrary1.DLL。

This question requires psychic debugging. 这个问题需要心理调试。 Fusion is asked to resolve a path on the I: drive. 要求Fusion解析I:驱动器上的路径。 That is often a mapped drive letter to a share on a file server. 这通常是映射到文件服务器上共享的驱动器号。 And often troublesome like this. 经常这样麻烦。 Given the excessive focus on security, ACE is liable to be the acronym for Access Control Entry . 考虑到对安全性的过分关注,ACE易于成为Access Control Entry的缩写。 Which makes it likely that the program uses impersonation to "explore" access rights. 这使得程序很可能使用模拟来“探索”访问权限。 Which makes it likely that Fusion can't figure out what the I: drive might refer to, drive mappings are a per-user setting. 这使得Fusion可能无法弄清楚I:驱动器可能指的是什么,驱动器映射是针对每个用户的设置。

Works okay early in the program because it still runs with the default user token. 在程序早期可以正常工作,因为它仍使用默认的用户令牌运行。 And works okay once the program is deployed since it now has a stable location that doesn't depend on a drive letter mapping. 程序一旦部署,就可以正常工作,因为它现在的位置稳定,不再依赖于驱动器号映射。

Not sure what to recommend, I am a charter member of the Geneva Convention on Programmer's Rights. 我不确定要提出什么建议,我是《日内瓦程序员权利公约》的特许成员。 Which demands that programmers can create and test programs on their local drive and install the kind of debugging tools they need to find out why their program doesn't work. 这就要求程序员可以在本地驱动器上创建和测试程序,并安装所需的调试工具,以查明其程序为何不起作用。 This is a problem that your IT staff needs to solve. 这是您的IT员工需要解决的问题。 If that gives you control over your dev machine back then you're ahead. 如果这样可以让您控制自己的开发机器,那么您将遥遥领先。 A likely outcome given the kind of hits that Google returns for a ".net debug project on mapped drive" query. 考虑到Google对于“映射驱动器上的.net调试项目”查询返回的命中情况,可能会产生结果。

暂无
暂无

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

相关问题 无法加载文件或程序集“Microsoft.Bcl.AsyncInterfaces,Version=1.0.0.0,Culture=neutral,PublicKeyToken=XX”或其依赖项之一 - Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XX' or one of its dependencies C#:无法加载文件或程序集&#39;OpenPop,Version = 2.0.4.369,Culture = neutral,PublicKeyToken = null&#39;或其依赖项之一 - C#: Could not load file or assembly 'OpenPop, Version=2.0.4.369, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法加载文件或程序集“BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null”或其依赖项之一 - Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法加载文件或程序集&#39;Dapper,Version = 1.8.0.0,Culture = neutral,PublicKeyToken = null&#39;或其依赖项之一 - Could not load file or assembly 'Dapper, Version=1.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies 无法从程序集“ EPaymentInvoicing,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空”中加载类型“ AgencySystem” - Could not load type 'AgencySystem' from assembly 'EPaymentInvoicing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 无法加载文件或程序集“Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey”或其依赖项之一。 - Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey' or one of its dependencies. 无法加载文件或程序集&#39;itextsharp,Version = 5.5.0.0,Culture = neutral,PublicKeyToken = 8354ae6d2174ddca&#39;或其依赖项之一 - Could not load file or assembly 'itextsharp, Version=5.5.0.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies 无法加载文件或程序集&#39;System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 561934e089&#39;或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=561934e089' or one of its dependencies 无法加载文件或程序集“工具,版本= 4.5.0.0,区域性=中性,PublicKeyToken = f7660c0f5438cda5”或其依赖项之一 - Could not load file or assembly 'Tools, Version=4.5.0.0, Culture=neutral, PublicKeyToken=f7660c0f5438cda5' or one of its dependencies 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM