2017-07-10 2 views
1

私のプロジェクトにC#とVB.Netを混在させようとしています。しかし、私はエラーが発生しています。私はすでにweb.configにこのコード行を残していますが、残念ながらまだエラーが出ています。ASP.NetエラーでC#とVB.Netを混ぜる

<compilation debug="true"> 
 
    <codeSubDirectories> 
 
     <add directoryName="VB" /> 
 
     <add directoryName="CSharp" /> 
 
    </codeSubDirectories> 
 
    </compilation> 
 
    
 
<system.codedom> 
 
    <compilers> 
 
     <compiler language="c#;cs;csharp" extension=".cs" 
 
       type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
 
       warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/> 
 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" 
 
       type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
 
       warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/> 
 
    </compilers> 
 
</system.codedom> 
 

ここで私が得ているエラーです。

enter image description here

私はすでに、これらの投稿に見hereherehere、およびhere。しかし、まだ私はエラーが発生しています。これを修正するには?ありがとうございました。あなたのエラーメッセージに

EDIT 全体のweb.config

<?xml version="1.0" encoding="utf-8"?> 
 
<!-- 
 
    For more information on how to configure your ASP.NET application, please visit 
 
    http://go.microsoft.com/fwlink/?LinkId=169433 
 
    --> 
 
<configuration> 
 
    <system.web> 
 
    <compilation debug="true" targetFramework="4.6.1"> 
 
     <codeSubDirectories> 
 
     <add directoryName="VB" /> 
 
     <add directoryName="CSharp" /> 
 
     </codeSubDirectories> 
 
    </compilation> 
 
    <httpRuntime targetFramework="4.6.1"/> 
 
    <httpModules> 
 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/> 
 
    </httpModules> 
 
    </system.web> 
 
    <system.codedom> 
 
    <compilers> 
 
     <compiler language="c#;cs;csharp" extension=".cs" 
 
     type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
 
     warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/> 
 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" 
 
     type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
 
     warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/> 
 
    </compilers> 
 
    </system.codedom> 
 
    <system.webServer> 
 
    <validation validateIntegratedModeConfiguration="false"/> 
 
    <modules> 
 
     <remove name="ApplicationInsightsWebTracking"/> 
 
     <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" 
 
     preCondition="managedHandler"/> 
 
    </modules> 
 
    </system.webServer> 
 
</configuration>

+0

@LeiYangあなたが何を意味するのですか?あなたは例を挙げることができますか? – Rich

+1

@LeiYangこれは当てはまりません。同じプロジェクトでC#とVBを混在させるには、 '.aspx'ファイル(コードビハインドファイルではない)と、同じファイルに2つの言語を混在させないでください。 – Dai

+0

targetFrameworkを変更または追加しようとしましたか? –

答えて

2

「system.web.extensionsが重複しています/ scripting/scriptResourceHandler 'セクションでが定義されています.NET 4.xアプリケーションプールで.NET 3.5プロジェクトを実行しようとすると、.NET 4.xのmachine.configに既にscriptResourceHandlerセクションがありますn)は%Windir%\Microsoft.NET\Framework\v4.0.30319\Config\machine.configにチェック:

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> 
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> 

     <!-- this section causing duplicate error for .NET 3.5 projects --> 
     <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/> 
     ... 
    </sectionGroup> 
</sectionGroup> 
また

あなたがのmachine.configと同じディレクトリにweb.configファイルをチェックしている場合、ScriptResourceHandlerは既にそこに登録されています

<httpHandlers> 
    ... 

    <!-- this handler is already registered in .NET 4.x default web.config --> 
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/> 

    ... 
</httpHandlers> 

をFYI、私がことがわかりました重複を削除してみ

<configSections> 
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
     <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> 
     <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" /> 
      <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
      <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" /> 
     </sectionGroup> 
     </sectionGroup> 
    </sectionGroup> 
</configSections> 

:.NET 3.5プロジェクトのconfigSections要素は、このようなscriptResourceHandlerセクションを持っています0セクションにconfigSectionsのバージョン3.5.0.0とマークされていて、もう一度ビルドしてください。または、プロジェクトをアップグレードしたくない場合は、IISアプリケーションプールを変更してバージョン2.0を使用してください。

NB:は、私は、.NET 3.5を使用して、VS 2010でテンプレートから新しいMVCプロジェクトを作成しようとしたとの両方のC#& VBがcompiler language="c#;cs;csharp" & compiler language="vb;vbs;visualbasic;vbscript"として利用できることがわかりました。

参考文献:

MSDN Blog: There is a duplicate scriptResourceHandler section defined

IIS7 deployment - duplicate 'system.web.extensions/scripting/scriptResourceHandler' section

+0

あなたが正しいです、もし私がタグを倍増し、すでに登録されていればそれは意味します。今、それは働いています。ありがとうございました! – Rich

0

ご注意ください。あなたは、同じプロジェクトにC#VBを実行することができます。エラーメッセージが述べ

enter image description here

通り:

定義された重複した 'system.web.extensions /スクリプト/ scriptResourceHandler' セクションがあります。あなたがネット4.0

に.NET 3.5ベースのアプリケーションを実行しているので、問題は、あなたがエラーを持っている理由は、私はあなたがすでに含まれている完全な、持っているセクションの定義に掲示要求あなたの完全なweb.config、です.NET 4.0のデフォルトの.configのルートweb.configにあります(%windir%\ microsoft.net \ framework \ v4.0.30319 \ config \ machine.configを参照)

+0

これは、あなたがネット4.0で.net 3.5ベースのアプリケーションを実行しているために_問題があることを意味していません。まだ、私は4.6.1フレームワークを使用しています。 **複製**は私がタグや何かの複製を持っていると言っていますか? – Rich

関連する問題