microsoft.build - Programmatically modify Assembly Binding -


I have a problem with which I should be sure to modify the following .exe.config file.

  & lt ;? XML version = "1.0"? & Gt; & Lt; Configuration & gt; & Lt; Order & gt; & Lt; Assembly binding xmlns = "urnchemas-microsoft-com: asm.v1" & gt; & Lt; DependentAssembly & gt; & Lt; Assembly ID name = "Microsoft.bild framework" publicKitokon = "b 03f5f7f11d50a3a" culture = "neutral" /> & Lt; Compulsive Redirect Old Version = "0.0.0.0- 99.9.9.9" New WordPress = "3.5.0.0" /> & Lt; / DependentAssembly & gt; & Lt; Assembly identity name = "Microsoft.Build.Engine" publicKeyToken = "b03f5f7f11d50a3a" culture = "neutral" /> & Lt; Compulsive Redirect Old Version = "0.0.0.0- 99.9.9.9" New WordPress = "3.5.0.0" /> & Lt; / DependentAssembly & gt; & Lt; / AssemblyBinding & gt; & Lt; / Order & gt; & Lt; / Configuration & gt;  

My problem is, I can not modify the file, I have to fix it by code, and I think that should be possible, right?

But how ?, how can I modify my application so that it moves like the above changes were made in the config file?

I was battling a similar problem. Use the important event. Here's how my code looks:

  Public Zero LoadStuff (string assembly file) {AppDomain.CurrentDomain.AssemblyResolve + = New ResolveEventHandler (CurrentDomain_AssemblyResolve); Var assembly = assembly.loadfom (assembly file); // Load a bunch of types from the assembly now ...} CurrentDomain_AssemblyResolve assembly (Object Sender, ResolveEventArgs Args) {var name = new association name (args.Name); If (name.Name == "FooLibrary") {return typeof (FooClass) Assembly; } Return tap; }  

This completely ignores the version number and uses the library already loaded for any library reference named "FooLibrary". If you want to be more restrictive, then you can use other features of the AssemblyName class FooClass in the FooLibrary assembly.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -