我有两个服务器,但通常运行相同的安装程序- IIS、SQL Server等。一个给我这个错误,另一个没有。我将相同的代码从Visual Studio发布到这两个服务器。
他们都在运行.NET CLR Version v4.0.30319,我相信它就是4.5。
Some answers说你必须以另一个版本为目标,如果我在visual studio中改变它,一切都会崩溃,所以不是这样。同样,相同的代码也在其他服务器上运行。
Other answers说一些旧的动态链接库可能是原因。我没有部署到工作服务器,所以可能复制了一些较新的DLL?但是我怎么知道呢?
此外,错误似乎不在我的代码中,而是在框架和Umbraco中,所以我认为我不应该进入并更新字符串函数或类似的东西:
[MissingMethodException: Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.Object)'.]
System.Net.Http.Headers.MediaTypeHeaderValue.CheckMediaTypeFormat(String mediaType, String parameterName) +0
System.Net.Http.Headers.MediaTypeHeaderValue..ctor(String mediaType) +33
System.Net.Http.Formatting.MediaTypeConstants..cctor() +45
[TypeInitializationException: The type initializer for 'System.Net.Http.Formatting.MediaTypeConstants' threw an exception.]
System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() +99
System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() +49
System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes) +255
System.Web.Http.GlobalConfiguration.<CreateConfiguration>b__0() +78
System.Lazy`1.CreateValue() +14308960
System.Lazy`1.LazyInitValue() +524
Umbraco.Web.WebBootManager.InitializeResolvers() +1530
Umbraco.Core.CoreBootManager.Initialize() +814
Umbraco.Web.WebBootManager.Initialize() +19
Umbraco.Core.UmbracoApplicationBase.StartApplication(Object sender, EventArgs e) +244
[HttpException (0x80004005): The type initializer for 'System.Net.Http.Formatting.MediaTypeConstants' threw an exception.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +588
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +181
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +322
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +452
[HttpException (0x80004005): The type initializer for 'System.Net.Http.Formatting.MediaTypeConstants' threw an exception.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +778一般来说,关于Google的信息不多,所以不确定可以做些什么。欢迎有任何见解!
发布于 2019-04-20 03:27:49
如果您查看documentation,似乎只有在.NET 4.6上才能使用重载。服务器可能具有不同的.NET框架版本。
.NET 4.5上最近的过载:
Format(IFormatProvider, String, Object[])在.NET 4.6上也有完全相同的重载:
Format(IFormatProvider, String, Object)确保两台服务器都正确安装了.NET 4.6。
https://stackoverflow.com/questions/55766829
复制相似问题