Where is Visual Studio looking for assemblies?

I have a framework that consists of many base classes that can be obtained for developing many applications. Among these classes is a subclass of System.Windows.Forms.Panel, for which I wrote my own constructor. Everything works fine with Visual Studio 2005, but something is wrong when I try to upgrade to VS2010. This is a simplified version of what I am doing:

I have a project called CoreClasse that contains an interface and two classes:

public interface IConf { string foo { get; set; } void InitFoo(); } public class SimpleClass { public string foo; } public class ConfLoader { public static IConf LoadConf() { AssemblyName anAssemblyName = new AssemblyName("ConfClasses"); Assembly anAssembly = Assembly.Load(anAssemblyName); IConf result = (IConf)anAssembly.CreateInstance("ConfClasses.ConfClass"); result.InitFoo(); return result; } } 

Then there is the ConfClasses project, which refers to CoreClasses and contains only one class that implements IConf:

 public class ConfClass : IConf { public SimpleClass confVal; public string foo { get { return confVal.foo; } set { confVal.foo = value; } } public void InitFoo() { confVal = new SimpleClass(); confVal.foo = "bar"; } } 

And finally, there is a project for controls that refers only to CoreClasses and contains a subclass of Panel and its associated constructor:

 [Designer("MyControls.Design.SimplePanelDesigner", typeof(IRootDesigner))] public class SimplePanel : Panel { public SimpleClass dummy = new SimpleClass(); } public class SimplePanelDesigner : DocumentDesigner { public IConf DesignerConf; public SimplePanelDesigner() : base() { DesignerConf = ConfLoader.LoadConf(); } } 

Now I am creating another solution that references all these DLLs and contains an empty subclass of SimplePanel. When I double-click on this class in SolutionExplorer, the SimplePanelDesigner constructor is executed and the LoadConf method from ConfLoader is called. This means that ConfClasses.dll is loaded dynamically and an instance of ConfClass is created. Everything is fine up to this point, but when InitFoo is called, this exception occurs:

Failed to load file or assembly "CoreClasses, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" or one of its dependencies. The system cannot find the specified file.

To make things harder, the exception was not actually raised in this example, but this is exactly what happens with my real application and the exception that I get. I have no idea what is going on here. VS implements the method that IS in CoreClasses. Why is he trying to download it again? And where is he looking for her? I also checked the current AppDomain, but it has CoreClasses among its loaded assemblies, and it does not seem to change.

To add more detailed information, each project is created in a shared folder (and not in the usual obj / debug folder inside the project folder), and there is no other copy of my DLLs on the PC at the moment I start my test operation. Then a copy of all the referenced DLLs is executed in a series of folders in the AppData \ Local \ Microsoft \ VisualStudio \ 10.0 \ ProjectAssemblies folder of my user profile, and this seems to be the place where VS looks for assemblies when Assembly.Load is executed, and I can find a copy of CoreClasses . I tried to clear all folders, rebuild everything, and keep different solutions open / closed in each combination, but without any improvements.

EDIT:

As suggested by GranMasterFlush, this is a FusionLog generated with the exception of:

 === Pre-bind state information === LOG: User = FCDB\fc0107 LOG: DisplayName = XEngine.Core, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: The same bind was seen before, and was failed with hr = 0x80070002. ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002). 

EDIT 2

To add some information, I looked at the merge logs generated in my simple example and found that when loading CoreClasses the exact same log is generated, but somehow VisualStudio finds a way to handle it.

+6
source share
2 answers

I just found out what's going on. The difference between a simple example and a fact is that AddIn is involved. This is quite a story, but that’s it.
As you can see from the sample code, I load the Confclasses DLL through reflection, so as not to add a link to it. This is normal at runtime, but the designer complains that he cannot pass IConf to IConf. This is due to the fact that CoreClasses.dll is loaded from AppData \ Local \ Microsoft \ VisualStudio \ 10.0 \ ProjectAssemblies when the designer starts, but ConfClasses.dll is loaded from my bin folder and therefore is its links, so there are two versions of CoreClasses.dll and various versions of IConf.
To work around the problem, I developed AddIn when the assembly loads Assembly.Load at design time, adds a link to this assembly and then clears the links when closing the last window of the constructor.
Everything was fine with VS2005, but using ProcMon.exe I found out that VS2010 added a new folder in which addins are looking for assemblies: Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ CommonExtensions \ DataDesign
I copied my assembly there and everything works again. Now you only need to find a way to add things there manually.

+4
source

Have you tried using the assembly binding viewer to find out why this failure to load assemblies?

http://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.71%29.aspx

Here is another article about usage:

http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57120.aspx

EDIT:

Where is the dll stored? This message describes a similar problem, and the problem is that the link to the DLL is not specified in the GAC, the executable directory, or a subfolder from the executable directory:

+2
source

Source: https://habr.com/ru/post/894357/


All Articles