Failed to load file or assembly 'XXX, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null' or one of its dependencies

I am trying to debug this error:

System.IO.FileNotFoundException: Failed to load file or assembly "ClassLibrary1, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" or one of its dependencies. The system cannot find the specified file. File name: 'ClassLibrary1, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null'

I see a lot of solutions and try them all.

I watch Fusion Viewer and I get the following message:

LOG: this binding starts in the context of the default load. LOG: Using the application configuration file: I: \ Projects \ ACE Explorer \ AceV_1Explorer \ AceExplorer \ AceExplorer \ bin \ Debug \ AceExplorer.exe.config LOG: Using the host configuration file: LOG: Using the machine configuration file from C: \ Windows \ Microsoft .NET \ Framework64 \ v4.0.30319 \ config \ machine.config. LOG: Post-policy link: ClassLibrary1, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null LOG: Search in the GAC was unsuccessful. LOG: attempt to load a new file URL: /// I: / Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.DLL. LOG: attempt to load a new file URL: /// I: / Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.DLL. LOG: attempt to load a new file URL: /// I: / Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.EXE. LOG: attempt to load a new file URL: /// I: / Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.EXE. LOG: all trial URLs were tried and failed.

I see the file in the directory, and Target is 4.0 for everyone using x86

Any ideas on what's broken

Update Sorry for the confusion. In the log, this was PublicKeyToken = null. I tried everything.

UPDATE I added code in the main program that will allow assemblies using ResolveEventHandler. It didn't work at first. But when I had a program, load these external assemblies (LoadReferences ()) at the beginning of the program, it works. Strange, since the path was exactly the same when I load them at the beginning of LoadReferences (), and then when the method enters a link to a custom assembly that runs CurrentDomain_AssemblyResolve. An empty path resolves the build path. As you can see, in LoadReferences () I am adding EntityFramework, which will cause the same problem, although I am using Nuget.

In Main (), I added:

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; } 

Besides. Not sure if that matters, but this is a click with full confidence.

Also our desktop computers are quite locked.

Also, for all projects, the platform is installed on x86.

+5
source share
1 answer

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

This question requires mental debugging. Fusion will ask for permission on the I: drive. This is a frequently mapped drive letter to a share on a file server. And often this is unpleasant. Given the excessive focus on security, ACE may be an acronym for Entry Control Entry . This makes it likely that the program uses impersonation to "examine" access rights. Most likely, Fusion cannot understand what an I: drive may have; drive mappings are for the user .

It works fine at the beginning of the program, because it still works with the user's default token. And it works fine when the program is deployed, since now it has a stable location, which does not depend on the mapping of drive letters.

Not sure what to recommend, I am a member of the Charter of the Geneva Convention on the Rights of a Programmer. This requires that programmers can create and test programs on their local drive and install the debugging tools that they need to find out why their program does not work. This is a problem that your IT staff must solve. If this gives you control of your dev machine, then you are ahead. The likely result, given the kind of hits that Google returns for the request .net debug project on mapped drive.

+3
source

All Articles