Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当我在getresponsedata上设置断点时,代码运行良好,但如果没有断点,代码将无法运行_C# - Fatal编程技术网

C# 当我在getresponsedata上设置断点时,代码运行良好,但如果没有断点,代码将无法运行

C# 当我在getresponsedata上设置断点时,代码运行良好,但如果没有断点,代码将无法运行,c#,C#,} 请注意,这不是全部代码。当我在GetResponseData上设置断点时,我需要帮助,因为我的代码运行得很好,但如果我没有设置断点,则不会产生响应。我尝试添加thread.sleep,因此它等待Web服务的响应,但仍然没有成功。我添加了注释。我应该在调用方法GetDataResponse之前检查第一个参数:BatchStatus。我再次阅读了API的文档。如果没有batchstatus,GetDataResponse将为空,因此代码在发布模式下挂起,仅在调试模式下工作 //webse

}


请注意,这不是全部代码。当我在
GetResponseData
上设置断点时,我需要帮助,因为我的代码运行得很好,但如果我没有设置断点,则不会产生响应。我尝试添加thread.sleep,因此它等待Web服务的响应,但仍然没有成功。我添加了注释。

我应该在调用方法
GetDataResponse
之前检查第一个参数:
BatchStatus
。我再次阅读了API的文档。如果没有
batchstatus
GetDataResponse
将为空,因此代码在发布模式下挂起,仅在调试模式下工作

    //webservice connection
 CRB_WEBSERVICE.CBS_SERVICE.BatchPublicServiceClient proxy = new CRB_WEBSERVICE.CBS_SERVICE.BatchPublicServiceClient("BasicHttpBinding_IBatchPublicService");
                    proxy.ClientCredentials.UserName.UserName = "";
                    proxy.ClientCredentials.UserName.Password = "";
                    string currdte = DateTime.Now.ToString("yyyyMMdd");
                    //Open Connection for webservice
                    proxy.Open();
    //batchid is a string requested in format the client wants
                    string batchid = "" + currdte + "_" + "D" + "_" + "**" + "_" + num + "_" + "XML" + "_" + "T"; 
//generatexml is generating an XML file which is then zipped and sent via //webservice
                    GenerateXML(batchid);
     try
                        {
//process to send zipped file via webservice

                            byte[] data = File.ReadAllBytes(batchid + ".zip");
                                     proxy.Begin(batchid);
                            proxy.PutData(batchid, 1, data);
                            proxy.Finish(batchid, 1);
                            var b = proxy.GetBatchInfo(batchid);
                          // thread so it waits for the response
                            Thread.Sleep(11000);
// this is where my issue is.if i put a breakpoint i get a response of a //zipped file. if i dont nothing happens
                           **var result = proxy.GetResponseData(batchid, 1);**
                            //Thread.Sleep(100);
                            System.IO.File.WriteAllBytes(@"C:\CBS_WEBSERVICE\Response.zip", result);

在不知道这些代码是什么的情况下,我们怎么可能提供帮助?什么是代理?什么是
batchid
GetResponseData
做什么?你为什么要执行
线程。睡眠
?如果你能提供一个链接,那就太棒了。@mjwills不知道如何粘贴整个代码,因为它正在连接到一个Web服务,然后会给我的机器带来响应。让我试着转寄这封信error@MarkusDeibel我添加了更多的代码并进行了解释。现在有意义了吗?请不要对所有内容都使用粗体格式;只是为了重要的单词或短语。
 var b = proxy.GetBatchInfo(batchid);

 while (b.BatchStatus != CRB_WEBSERVICE.CBS_SERVICE.BatchStatuses.Finished)
                        {
                            b = proxy.GetBatchInfo(batchid);
                        }
if (b.BatchStatus == CRB_WEBSERVICE.CBS_SERVICE.BatchStatuses.Finished)
                        {
                            if (b.BatchResult == CRB_WEBSERVICE.CBS_SERVICE.BatchResults.Success)
                            {  
                                var result = proxy.GetResponseData(batchid, 1);
}
}