Created
March 13, 2013 23:07
-
-
Save Yegoroff/5157326 to your computer and use it in GitHub Desktop.
AssemblyResolver for Newtonsoft.Json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<!-- Commented out binding redirect. | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" /> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime>--> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
// Referenced PlainElastic Nuget package and manually removed bibdingredirects from app.config | |
namespace ConsoleApplication7 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); | |
var c = new MyClass(); | |
c.Test(); | |
Console.ReadKey(); | |
} | |
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | |
{ | |
var name = new AssemblyName(args.Name); | |
if (name.Name == "Newtonsoft.Json") | |
{ | |
return typeof(Newtonsoft.Json.JsonConvert).Assembly; | |
} | |
return null; | |
} | |
} | |
class MyClass | |
{ | |
public void Test() | |
{ | |
var co = new PlainElastic.Net.Serialization.JsonNetSerializer(); | |
var s = co.Serialize("tests"); | |
Console.WriteLine("OK"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment