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.