3

Web.Config 変換が公開されていません。エラーは、表示されているこれらの警告に関係していると思います。

Visual Studio 2010 を使用して、Web.Config/Web.Config.Debugファイルをいじっています。

私の.Debugファイルには、次の警告が何度も表示されます。

No element in the source document matches '/configuration'

ファイルに存在するセクションごとにリストされていると思い.Debugます。

したがって、次のサンプル Web.Config.Debug ファイルでは、2 回リストされます。(私は推測しています、最初のものは用<connectionStrings>..</>で、2番目は用です<system.webServer>...</.>

<?xml version="1.0"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:SupressWarnings="false">

    <connectionStrings>
        <add name="Foo" connectionString="Server=foo;Database=Foo;uid=foo;password=foo" providerName="System.Data.SqlClient"
            xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>

    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <clear />
                <add name="ETag" value="Dev_IIS" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>

</configuration>

誰でも助けてもらえますか?

4

2 に答える 2

3

トランスフォーマーが xmlns= 属性で窒息していることを示唆するこのブログ投稿を見つけました。

Web.config ファイルを次のように変更しました。

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    etc...

これに:

<configuration>
  <connectionStrings>
    etc...

...そして見よ、それはうまくいく!

于 2012-09-26T03:51:36.337 に答える
0

新しい Web アプリケーション プロジェクト (.net 4.0 をターゲット) を作成し、Web.Release.config を変更して、上で貼り付けたものを正確に含めます。次に、web.config に移動し、以下を追加しました。

    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
    <add name="Foo" />  <------------------------added this
  </connectionStrings>

次に、Web アプリケーションをリリースして公開するように構成を変更しました。公開されたアプリケーションには、web.config に次のものが含まれていました

<add name="ApplicationServices"
     connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />
<add name="Foo"
     connectionString="Server=foo;Database=Foo;uid=foo;password=foo"
     providerName="System.Data.SqlClient" />  <-------this got added

したがって、あなたのケースのどこに問題があるのか​​ わかりません。

于 2010-06-23T02:20:29.737 に答える