1

こんにちは、タイトルに記載されているようにこのエラーが発生しているため、WCF を介してコンサルタント リストを取得しようとしています。デバッグ中にすべてのコードを教えて、エラーのトレース場所を取得します。

ロード時にフォームを実行すると、

    private void LoadData()
    {
        try
        {
            CIService.CIServiceClient serv = new CIServiceClient();
            serv.GetConsultantListCompleted += new EventHandler<GetConsultantListCompletedEventArgs>(serv_GetConsultantListCompleted);
            serv.GetConsultantListAsync();
            serv.Close();
        }
        catch (Exception ex)
        {
            string error = "<script language=javascript>alert('Failed to Load Consultants at PageLoad \r\n" + ex.StackTrace + "');</script>";
            if (!ClientScript.IsClientScriptBlockRegistered("ConLoadErr"))
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "ConLoadErr", error);  
        }
    }

 public ConsultantService():base(connectionString)
        {

        }

    public DataAccessBase(string connectionString)
        {
            this.sqlCommand = new SqlCommand();
            this.sqlConnection = new SqlConnection(connectionString);
            this.sqlCommand.Connection = this.sqlConnection;
            this.commandType = System.Data.CommandType.Text;
        }

  List<Consultant> ICIService.GetConsultantList()
        {
            ConsultantService service = new ConsultantService();
            return service.GetConsultantList();
        }

    public List<Consultant> GetConsultantList()
        {
            DataAccessManager.SystemSetup sysSetup = new SystemSetup();
            return sysSetup.GetConsultantList();
        }

 public List<Consultant> GetConsultantList()
        {
            InspectionEntities dbContext = new InspectionEntities();
            return dbContext.Consultants.ToList();
        }

    public InspectionEntities() : 
                base("name=InspectionEntities", "InspectionEntities")
        {
            this.OnContextCreated();
        }

  public List<Consultant> GetConsultantList()
        {
            InspectionEntities dbContext = new InspectionEntities();
            return dbContext.Consultants.ToList();
        }

再び戻ると、「return dbContext.Consultants.ToList();」でエラーが発生します。

Inner Exception ({"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"})

Stack Trace

   at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
   at System.Data.EntityClient.EntityConnection.Open()
   at System.Data.Objects.ObjectContext.EnsureConnection()
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at DataAccessManager.SystemSetup.GetConsultantList() in G:\Design Scoring\DataAccessManager\SystemSetup.cs:line 42
   at InspectionServices.ConsultantService.GetConsultantList() in G:\Design Scoring\InspectionServices\Services\ConsultantService.cs:line 112
   at InspectionServices.CIService.InspectionServices.ICIService.GetConsultantList() in G:\Design Scoring\InspectionServices\CIService.cs:line 253
   at SyncInvokeGetConsultantList(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

あなたの提案を願っています

ありがとう

EDITED:もう1つ言いたいのは、このアプリケーションの他の形式では、エラーなしでdbからデータを取得していることです

4

0 に答える 0