你好,互联网用户,
我遇到了与Json.net软件包版本不匹配的问题,因此我无法排除故障。
问题:我正在尝试安装依赖于Newtonsoft的Json.net的测试模拟框架。我从Nuget通过Visual Studio抓取了Json.net版本6.0.3。根据安装程序的packages.config,它应该是在寻找Newtonsoft.json v.6.0.3。那里没有明显的问题。
然而,当我运行生成的exe时,我收到以下错误:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been
thrown by the target of an invocation. ---> System.IO.F
ileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or on
e of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor()
at System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters()
at System.Web.Http.HttpConfiguration.DefaultFormatters()
at System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes)
at System.Web.Http.HttpConfiguration..ctor()
at JSendMock.Service.Startup.Configuration(IAppBuilder appBuilder)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo cultur
e)
at Owin.Loader.DefaultLoader.<>c__DisplayClass12.<MakeDelegate>b__b(IAppBuilder builder)
at Owin.Loader.DefaultLoader.<>c__DisplayClass1.<LoadImplementation>b__0(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](String url)
at JSendMock.Service.Program.Main(String[] args)
所以对我来说明显的解释是它似乎在寻找错误的版本或寻找错误的地方。可执行文件应搜索的6.0.3 Newtonsoft.json版本与可执行文件位于同一目录中。全局程序集缓存中没有Newtonsoft.json,并且没有其他明显因素影响搜索。除此之外,我对于它为什么会出现版本不匹配或如何解决此问题感到困惑。
在不同目录中的同一台机器上还有其他几个Newtonsoft.json副本,来自许多不同版本。我尝试用6.0.3的副本替换它们,以测试可执行文件是否以某种方式指向Newtonsoft.json dll的不同副本。除此之外,我不确定如何排除故障。
感谢任何帮助。