Assembly optimized from assembly

I have an assembly fully populated with classes that implement interfaces in another assembly. For instance:

Main Assembly (Reference to both assemblies) Shared Assembly -----IModule Class Assembly (Reference to shared assembly) -----unknownType : IModule -----unknownType2 : IModule 

The main assembly is not directly related to any of the assembly types of the class. I am looking for the following types:

 // Load all referenced assemblies: Assembly.GetExecutingAssembly().GetReferencedAssemblies() .Except(AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName())) .Distinct() .ToList() .ForEach(act => Assembly.Load(act)); // Find all instances of IModule in loaded assemblies: var modules = from asm in AppDomain.CurrentDomain.GetAssemblies() from provider in asm.GetTypes() where typeof(IModule).IsAssignableFrom(provider) ...instantiate type etc... 

If I have a reference to only an arbitrary type in the assembly of classes, then it appears in GetReferencedAssemblies, loads and returns correctly - but as soon as I delete the reference to the type, it is not transferred to the assembly directory or displayed as a reference assembly, which leads to failure downloads.

Is there a way to get VS to include this assembly in the output directory? The main application should not know any of the types in the class assembly.

+5
source share
1 answer

I think I have your problem, but can you clarify your question? Do you expect the assembly that you added as a link to your project to be copied to your output folder with your application? How did you add the link? Is it the DLL or .exe that you looked at in the file dialog box, or is it the COM or GAC assembly that you selected from the list in the Add Links dialog box?

If you viewed it and it is not in the GAC directory, such an optimization is expected. Select the link in Solution Explorer and verify that the Copy Local property field is set to True. You can try toggling this option even if it is. Your .vsproj file just needs to be rebuilt to include the link.

If you try to reference the .dll from the name of a file stored in a string or selected at run time, then Visual Studio will not know that your application is using it, however, to copy it to your output directory. It should not be too difficult to do with File.Copy, though, if you have a path to the DLL.

-1
source

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


All Articles