1

ASP.NETWebサイトで次のエラーが発生します。別のPCに移動しました。IISを実行し、SQL Server Expressを実行し、データソースのマシン名を新しいマシン名に変更しました。ただし、DBアクセスのあるページでは、スクリーンショットに示すエラーが発生します。 アプリケーションのサーバーエラー

Innovations-news.aspxは、次のように新しいDataContextを作成します。

dataContext = new DataContext(Config.ConnectionString);

My Configクラスは、現在のIPに基づいて接続文字列を返します。例えば:

return ConfigurationManager.ConnectionStrings["Development"].ConnectionString;

これはweb.configにあります:

<connectionStrings>
<add name="Development" connectionString="Data Source=WORK51C0\SQLEXPRESS;Initial Catalog=Jri;Integrated Security=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>

以下はLinqToSql1.designer.csからのものです

public DataContext() : 
            base(global::Jri.Data.Properties.Settings.Default.JriConnectionString1, mappingSource)
    {
        OnCreated();
    }

    public DataContext(string connection) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

    public DataContext(System.Data.IDbConnection connection) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

    public DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

    public DataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

これをデバッグするための最良の方法に関するアドバイスはありますか?または、おそらくあなたも何が悪いのか知っていますか?!

ありがとう、

4

2 に答える 2

0

OK、これは ConfigurationManager を使用した My Config クラスへのアクセスの問題でした。したがって、私の一時的な解決策は、接続文字列を web.config から取得するのではなく、このクラスから直接出力することでした。

于 2012-06-14T10:07:14.043 に答える