首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >找不到方法:'System.Collections.ObjectModel.Collection`1

找不到方法:'System.Collections.ObjectModel.Collection`1
EN

Stack Overflow用户
提问于 2019-06-13 02:33:19
回答 1查看 2.2K关注 0票数 2

嗨,当我发布我的WebService时,我得到了这个关注的错误,

找不到System.Net.Http.Formatting.MediaTypeFormatter.get_SupportedMediaTypes()'. 方法:'System.Collections.ObjectModel.Collection`1

但当我在VS调试模式下使用它时,就不会发生这种情况。我已经在谷歌上搜索过了,并尝试在webconfig上使用程序集引用,但它不起任何作用?

这是我当前的webconfig文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
<system.web>
    <customErrors mode="Off"/>
</system.web>
<system.webServer>
    <httpErrors errorMode="Detailed" />
</system.webServer>

  <system.web>
    <httpRuntime executionTimeout="3000000" maxRequestLength="1048576" />
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <authentication mode="Windows" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
  </system.web>
  <runtime>
       <dependentAssembly>
           <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
           <bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
        </dependentAssembly>
  </runtime>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000" />
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>


</configuration>

这是抛出错误的类

代码语言:javascript
复制
class WebApiConfig
{
    public static void Register(HttpConfiguration configuration)
    {
        configuration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

        configuration.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
            new { id = RouteParameter.Optional });
    }
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56568407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档