assemblies

How to prevent a .NET application from loading/referencing an assembly from the GAC?

。_饼干妹妹 提交于 2019-11-26 17:47:06
问题 Can I configure a .NET application in a way (settings in Visual Studio) that it references a "local" assembly (not in GAC) instead of an assembly within the GAC, although both assemblies have the same name and the same version? 回答1: If both assemblies are strong-named (signed), the CLR will always load from the GAC. Here are the steps the runtime uses to resolve assembly references (from How the Runtime Locates Assemblies): Determines the correct assembly version by examining applicable

Howto load assemby at runtime before AssemblyResolve event?

假装没事ソ 提交于 2019-11-26 17:46:31
问题 Actually i tried to implement some kind of 'statically linked' assemblies, within my solution. So i tried the following: Adding a reference to my assembly with CopyLocal = false Adding the .dll file itself to my solution with 'Add as link' Adding the .dll file itself to my resources with 'Add Resource' - 'Add Existing File' Adding some type out of my assembly into Form1 as private MyObject temp = new MyObject(); After these steps i got the FileNotFoundException as expected. So let's try to

How to save DLLs in a different folder when compiling in Visual Studio?

心不动则不痛 提交于 2019-11-26 17:38:44
问题 Let's suppose I have a Window Forms / Console Application C# project with some external references and references to other class library projects in the same solution too. When I build the Window Form project, I want the referenced libraries be stored in a different location (eg: bin\Release\Libraries ), and not in the same folder as the .exe . Is it possible to do? 回答1: There are 2 parts of your question: How to configure solutions to build assemblies/EXE into folders of your choice - this

How did Microsoft create assemblies that have circular references?

冷暖自知 提交于 2019-11-26 17:04:10
In the .NET BCL there are circular references between: System.dll and System.Xml.dll System.dll and System.Configuration.dll System.Xml.dll and System.Configuration.dll Here's a screenshot from .NET Reflector that shows what I mean: How Microsoft created these assemblies is a mystery to me. Is a special compilation process required to allow this? I imagine something interesting is going on here. I can only tell how the Mono Project does this. The theorem is quite simple, though it gives a code mess. They first compile System.Configuration.dll, without the part needing the reference to System

C#: How to load assembly from GAC?

拟墨画扇 提交于 2019-11-26 17:03:00
问题 I have "mycomp.myassembly.dll" in GAC but Load and LoadFrom throws file not found exception and LoadWithPartialName returns null. I'm doing the following: AssemblyName name = new AssemblyName(); name.Name = "mycomp.myassembly.dll"; Assembly assembly = Assembly.Load(name); fails with FileNotFound for mycomp.myassembly.dll file, and Assembly assembly = Assembly.Load("mycomp.myassembly.dll"); fails with exactly the same message. I double checked that assembly is in GAC (and even did gacutil /if

How do I get the version of an assembly without loading it?

北城余情 提交于 2019-11-26 16:51:55
问题 One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process. 回答1: I found the following in this article. using System.Reflection; using System.IO; ... // Get current and updated assemblies AssemblyName currentAssemblyName = AssemblyName.GetAssemblyName

Is it possible to replace a reference to a strongly-named assembly with a “weak” reference?

十年热恋 提交于 2019-11-26 16:42:43
问题 I'm writing a .NET tool that requires the SQL Server SMO library. I don't care if it's the version from Server 2005 (9.0), 2008 (10.0) or 2008 R2 (probably 10.5, didn't check). The SMO library is installed together SQL Server, so I can safely assume that on any system with SQL Server installed, some version of the SMO library is available as well. Unfortunately, the SMO libraries are strongly-named: If I add a reference to SMO 9.0 in my project, it will fail ( FileNotFoundException ) if only

Loading multiple versions of the same assembly

你说的曾经没有我的故事 提交于 2019-11-26 16:36:00
I'm working with a third-party assembly and unfortunately I now need to load their latest and a previous version into my project so at runtime I can decide which one to load. I only ever need one, not both. With this in mind, I am also dependent upon the types provided by the components so I cannot load from reflection and query every time for the method/events/interfaces that I want to use. I have seen some mention of handling this via AppDomain s but am not sure how to proceed. Would the process be to code against one version of the component and then at run-time (using the AppDomain ) swap

Modify Emdeded String in C# compiled exe

半世苍凉 提交于 2019-11-26 16:28:32
问题 I have an issue where I need to be able to have a compiled exe ( .net 3.5 c# ) that I will make copies of to distribute that will need to change a key for example before the exe is sent out. I cannot compile each time a new exe is needed. This is a thin client that will be used as part of a registration process. Is it possible to add a entry to a resource file with a blank value then when a request comes in have another application grab the blank default thin client, copy it, populate the

using ILMerge with .NET 4 libraries

不羁岁月 提交于 2019-11-26 15:43:03
问题 Two problems: 1) Basic .NET Assembly Not Included in ILMerged Assembly I'm having trouble using ILMerge in my post-build after upgrading from .NET 3.5/Visual Studio 2008 to .NET 4/Visual Studio 2010. I have a Solution with several projects whose target framework is set to ".NET Framework 4". I use the following ILMerge command to merge the individual project DLLs into a single DLL: if not $(ConfigurationName) == Debug if exist "C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" "C:\Program