本文介绍了帮助对象:"/"应用程序中的服务器错误.无法加载文件或程序集"System.Diagnostics.DiagnosticSource"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2017中创建了一个在本地运行良好的Web应用程序.但是,当我将其发布到Azure时,我会得到

I have created a web app in VS2017 that runs fine locally. But when I publish it to Azure I get 

""/"应用程序中的服务器错误.
无法加载文件或程序集"System.Diagnostics.DiagnosticSource"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配."

"Server Error in '/' Application.
Could not load file or assembly 'System.Diagnostics.DiagnosticSource' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference."

我已经更新到最新的System.Net.Http Nuget包,但是错误仍然存​​在.感谢您的帮助,我只是一无所获.

I have updated to the latest System.Net.Http Nuget package but the error persists. Any help is appreciated I am just plain stuck.

这是我的web.config

Here is my web.config


<?xml version ="1.0" encoding ="utf-8"?>

<!-
 有关如何配置ASP.NET应用程序的更多信息,请访问
  https://go.microsoft.com/fwlink/?LinkId=169433
  ->
< configuration>
  < configSections>
    <!-有关Entity Framework配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468->
    <节名="entityFramework";类型="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,版本= 6.0.0.0,Culture =中性,PublicKeyToken = b77a5c561934e089". requirePermission ="false"; />
  </configSections>
  < system.diagnostics>
    < trace>
      <侦听器>
        <添加类型="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,Microsoft.WindowsAzure.Diagnostics,版本= 2.8.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35" name ="AzureDiagnostics">
          <过滤器类型=" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <!-connectionStrings>
      < add name =" DefaultConnection" connectionString =数据源=(LocalDb)\ MSSQLLocalDB; AttachDbFilename = | DataDirectory | \ aspnet-WebRole1-20181202075823.mdf; Initial Catalog = aspnet-WebRole1-20181202075823; Integrated Security = True"; providerName ="System.Data.SqlClient; Trusted_Connection = True" />
  </connectionStrings->

  < connectionStrings>
     < add name =" ConnectionStringName" providerName ="System.Data.SqlClient"; connectionString =数据源= tcp:ServerName.database.windows.net,1433;初始目录=数据库名称;集成安全性= False;用户ID =用户名@服务器名称; Password =密码; Encrypt = True; TrustServerCertificate = False; MultipleActiveResultSets =真实" />
  </connectionStrings>




  < system.web>
    <认证模式=无". />
    < compilation debug ="true"; targetFramework ="4.6.1". />
    < customErrors mode =关"; />
    < httpRuntime targetFramework ="4.6.1"; />
    < pages>
      < namespaces>
        < add namespace ="System.Web.Optimization"; />
        < add namespace ="Microsoft.AspNet.Identity"; />
      </namespaces>
      < controls>
        <添加程序集="Microsoft.AspNet.Web.Optimization.WebForms". namespace ="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix ="webopt". />
      </controls>
    </pages>
    <成员身份>
      < providers>
        <!-
     在此模板中禁用了ASP.NET成员资格.请访问以下链接https://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的ASP.NET成员资格支持.
        ->
        <清除/>
      </providers>
    </membership>
    < profile>
      < providers>
        <!-
     在此模板中禁用了ASP.NET成员资格配置文件.请访问以下链接https://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的ASP.NET成员资格支持.
        ->
        <清除/>
      </providers>
    </profile>
    < roleManager>
      <!-
       在此模板中禁用了ASP.NET成员资格角色.请访问以下链接https://go.microsoft.com/fwlink/?LinkId=301889,以了解此模板中的ASP.NET成员资格支持.
        ->
      < providers>
        <清除/>
      </providers>
    </roleManager>
    <!-
           如果要部署到具有多个Web服务器实例的云环境中,
           您应将会话状态模式从"InProc"更改为到自定义".另外,
           更改名为"DefaultConnection"的连接字符串连接到实例
            SQL Server(包括SQL Azure和SQL Compact)而不是SQL Server Express.
      ->
    < sessionState mode ="InProc" customProvider =" DefaultSessionProvider">
      < providers>
        < add name =" DefaultSessionProvider"类型="System.Web.Providers.DefaultSessionStateProvider,System.Web.Providers,版本= 2.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35". connectionStringName =" DefaultConnection" />
      </providers>
    </sessionState>
    < httpModules>
      <添加名称="TelemetryCorrelationHttpModule";类型="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule,Microsoft.AspNet.TelemetryCorrelation". />
    </httpModules>
  </system.web>
  < system.webServer>
    < httpErrors errorMode =详细"; />
    < asp scriptErrorSentToBrowser =" true" />
    < modules>
      <删除名称="FormsAuthentication"; />
      <删除名称="TelemetryCorrelationHttpModule"; />
      <添加名称="TelemetryCorrelationHttpModule";类型="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule,Microsoft.AspNet.TelemetryCorrelation". preCondition ="managedHandler". />
    </modules>
    < validate validateIntegratedModeConfiguration ="false"; />
  </system.webServer>
  < runtime>
    < assemblyBinding xmlns ="urn:schemas-microsoft-com:asm.v1">
      < dependentAssembly>
        < assemblyIdentity name ="Antlr3.Runtime"; publicKeyToken ="eb42632606e9261f"; />
        < bindingRedirect oldVersion =" 0.0.0.0-3.5.0.2"; newVersion ="3.5.0.2" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" Newtonsoft.Json" publicKeyToken ="30ad4fe6b2a6aeed"; />
        < bindingRedirect oldVersion =" 0.0.0.0-12.0.0.0" newVersion ="12.0.0.0&"; />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" System.Diagnostics.DiagnosticSource" publicKeyToken ="cc7b13ffcd2ddd51"; />
        < bindingRedirect oldVersion =" 0.0.0.0-4.0.4.0"; newVersion ="4.0.4.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name ="WebGrease"; publicKeyToken ="31bf3856ad364e35" />
        < bindingRedirect oldVersion ="0.0.0.0-1.6.5135.21930&"; newVersion ="1.6.5135.21930&"; />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name ="EntityFramework"; publicKeyToken ="b77a5c561934e089" />
        < bindingRedirect oldVersion ="0.0.0.0-6.0.0.0" newVersion ="6.0.0.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name ="Microsoft.Owin"; publicKeyToken ="31bf3856ad364e35" />
        < bindingRedirect oldVersion ="0.0.0.0-4.0.0.0"; newVersion ="4.0.0.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" Microsoft.Owin.Security.OAuth" publicKeyToken ="31bf3856ad364e35" />
        < bindingRedirect oldVersion ="0.0.0.0-4.0.0.0"; newVersion ="4.0.0.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" Microsoft.Owin.Security.Cookies" publicKeyToken ="31bf3856ad364e35" />
        < bindingRedirect oldVersion ="0.0.0.0-4.0.0.0"; newVersion ="4.0.0.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" Microsoft.Owin.Security" publicKeyToken ="31bf3856ad364e35" />
        < bindingRedirect oldVersion ="0.0.0.0-4.0.0.0"; newVersion ="4.0.0.0" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" System.Net.Http" publicKeyToken ="b03f5f7f11d50a3a"文化=中立" />
        < bindingRedirect oldVersion ="0.0.0.0-4.1.1.3" newVersion ="4.1.1.3" />
      </dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity name =" Microsoft.Azure.KeyVault.Core" publicKeyToken ="31bf3856ad364e35"文化=中立" />
        < bindingRedirect oldVersion ="0.0.0.0-3.0.0.0"; newVersion ="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  < entityFramework>
    < defaultConnectionFactory类型="System.Data.Entity.Infrastructure.LocalDbConnectionFactory,EntityFramework"<
      <参数>
        <参数值="mssqllocaldb"; />
      </参数>
    </defaultConnectionFactory>
    < providers>
      < provider invariantName =" System.Data.SqlClient" type ="System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  < system.codedom>
    < compilers>
      < compiler language ="c#; cs; csharp" extension =.cs" type ="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version = 2.0.1.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35" warningLevel ="4"; editorOptions ="/langversion:默认/nowarn:1659; 1699; 1701" />
      < compiler language ="vb; vbs; visualbasic; vbscript"; extension =.vb" type ="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version = 2.0.1.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35" warningLevel ="4";编辑器选项="/langversion:默认/nowarn:41008/定义:_MYTYPE = \&"Web \&" /optionInfer +" />
    </compilers>
  </system.codedom>
</configuration>

<!--
  For more information on how to configure your ASP.NET application, please visit
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <!--connectionStrings>
      <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebRole1-20181202075823.mdf;Initial Catalog=aspnet-WebRole1-20181202075823;Integrated Security=True" providerName="System.Data.SqlClient;Trusted_Connection = True" />
  </connectionStrings-->

  <connectionStrings>
     <add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:ServerName.database.windows.net,1433;Initial Catalog=DatabaseName;Integrated Security=False;User Id=username@servername;Password=password;Encrypt=True;TrustServerCertificate=False;MultipleActiveResultSets=True" />
  </connectionStrings>




  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.6.1" />
    <customErrors mode="Off" />
    <httpRuntime targetFramework="4.6.1" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
        <add namespace="Microsoft.AspNet.Identity" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
    <membership>
      <providers>
        <!--
      ASP.NET Membership is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
        <clear />
      </providers>
    </membership>
    <profile>
      <providers>
        <!--
      ASP.NET Membership Profile is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
        <clear />
      </providers>
    </profile>
    <roleManager>
      <!--
        ASP.NET Membership Role is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
        -->
      <providers>
        <clear />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
    <httpModules>
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" />
    </httpModules>
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true" />
    <modules>
      <remove name="FormsAuthentication" />
      <remove name="TelemetryCorrelationHttpModule" />
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Azure.KeyVault.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>


推荐答案

此外,请查看Azure WebApp:对'/'应用程序中的服务器错误"博客进行故障排除,以进一步缩小问题范围,并让我们知道如何进行进一步调查.

Also, checkout the suggestions outlined inAzure WebApp: Troubleshooting "Server Error in ‘/’ Application" blog to further narrow down the issue and let us know how that goes for further investigation.


这篇关于帮助对象:"/"应用程序中的服务器错误.无法加载文件或程序集"System.Diagnostics.DiagnosticSource"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 16:17