Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies

后端 未结 17 2387
渐次进展
渐次进展 2020-12-03 00:43

I have a WinJS project that is previously built on Windows 8.1 using VS 2013.

Recently I upgraded this project to Universal Windows 10 by creating a blank Javascrip

17条回答
  •  隐瞒了意图╮
    2020-12-03 01:35

    I think AutoCAD hijacked mine. The solution which worked for me was to hijack it back. I got this from https://forums.autodesk.com/t5/navisworks-api/could-not-load-file-or-assembly-newtonsoft-json/td-p/7028055?profile.language=en - yeah, the Internet works in mysterious ways.

    // in your initilizer ...
    AppDomain currentDomain = AppDomain.CurrentDomain;
    currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
    
    .....
    
    private Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)
    {
        if (args.Name.Contains("Newtonsoft.Json"))
        {
            string assemblyFileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Newtonsoft.Json.dll";
            return Assembly.LoadFrom(assemblyFileName);
        }
        else
            return null;
    }
    

提交回复
热议问题