简体   繁体   English

找不到方法:'System.String System.String.Format(System.IFormatProvider,System.String,System.Object)'

[英]Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.Object)'

I have two servers but running generally the same setups - IIS, SQL Server, etc. One gives me this error, the other doesn't. 我有两台服务器但运行一般相同的设置 - IIS,SQL Server等。一个给了我这个错误,另一个没有。 I publish the same code from Visual Studio to both. 我从Visual Studio发布相同的代码到两者。

They are both running .NET CLR Version v4.0.30319 , which I believe is 4.5 . 他们都运行.NET CLR Version v4.0.30319 ,我相信是4.5

Some answers say you have to target another version, If I change that in visual studio, everything breaks, so it is not that. 一些答案说你必须针对另一个版本,如果我在visual studio中改变它,一切都会破坏,所以不是那样。 Also, the same code runs on the others server. 此外,相同的代码在其他服务器上运行。

Other answers say that some old DLL's could be the reason. 其他答案说,一些旧的DLL可能是原因。 I didn't deploy to the working server, so maybe some newer DLLs were copied? 我没有部署到工作服务器,所以可能会复制一些较新的DLL? But how could I know? 但我怎么知道呢?

Also, the error doesn't seem to be in my code, rather in the framework and Umbraco, so I don't think I should be going in and updating string functions or something like that: 此外,错误似乎不在我的代码中,而是在框架和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

Generally, there isn't much info on Google, so not sure what could be done. 一般来说,Google上的信息不多,所以不确定可以做些什么。 Any insights are welcome! 欢迎任何见解!

If you check out documentation , that overload seem to be available only on .NET 4.6. 如果您查看文档 ,那么该重载似乎仅在.NET 4.6上可用。 It is possible that servers has different .NET Framework versions. 服务器可能具有不同的.NET Framework版本。

Closest overload on .NET 4.5: .NET 4.5上最近的重载:

Format(IFormatProvider, String, Object[])

On .NET 4.6 there is exactly same overload: 在.NET 4.6上有完全相同的重载:

Format(IFormatProvider, String, Object)

Ensure that both servers has .NET 4.6 installed properly. 确保两台服务器都已正确安装.NET 4.6。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 方法未找到:&#39;System.String System.String.Format(System.IFormatProvider, System.String, System.Object) - Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.Object) 错误-LINQ to Entities无法识别方法&#39;System.String ToString(System.IFormatProvider)&#39; - Error - LINQ to Entities does not recognize the method 'System.String ToString(System.IFormatProvider)' LINQ to Entities无法识别MVC5中的方法&#39;System.DateTime ParseExact(System.String,System.String,System.IFormatProvider)&#39;方法错误 - LINQ to Entities does not recognize the method 'System.DateTime ParseExact(System.String, System.String, System.IFormatProvider)' method error in MVC5 找不到方法:'无效 System.Diagnostics.Tracing.FrameworkEventSource.BeginGetResponse(System.Object,System.String)' - Method not found: 'Void System.Diagnostics.Tracing.FrameworkEventSource.BeginGetResponse(System.Object, System.String)' 找不到方法:'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)' - Method not found: 'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)' 无法将“ System.Object []”转换为类型“ System.String []” - Cannot convert 'System.Object[]' to the type 'System.String[]' 无法将类型“ System.String”强制转换为类型“ System.Object” - Unable to cast the type 'System.String' to type 'System.Object' System.Object[] 不能转换为 System.String[] - System.Object[] can't be converted to System.String[] LINQ to Entities无法识别方法&#39;System.Object Parse(System.Type,System.String)&#39; - LINQ to Entities does not recognize the method 'System.Object Parse(System.Type, System.String)' LINQ to Entities 无法识别“System.Object get_Item(System.String)”方法 - LINQ to Entities does not recognize the method 'System.Object get_Item(System.String)' method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM