Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.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# 从Win32服务调用WCF服务时,我遇到System.StackOverflowException异常_C#_.net_Web Services_Wcf_Windows Services - Fatal编程技术网

C# 从Win32服务调用WCF服务时,我遇到System.StackOverflowException异常

C# 从Win32服务调用WCF服务时,我遇到System.StackOverflowException异常,c#,.net,web-services,wcf,windows-services,C#,.net,Web Services,Wcf,Windows Services,我有win32服务,每3秒钟通过WCF服务轮询一次数据库, 20小时后,我得到了一个例外: “System.StackOverflowException”类型的未处理异常 在win32服务的System.dll中发生 var methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; var traceProperties = new Dictionary<string

我有win32服务,每3秒钟通过WCF服务轮询一次数据库, 20小时后,我得到了一个例外:

“System.StackOverflowException”类型的未处理异常 在win32服务的System.dll中发生

            var methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            var traceProperties = new Dictionary<string, object>();
            Logger.LogTrace("Start ", methodName, traceProperties);

            Com.Softechww.Services.ContentInfo.EncodingJobs jobs = null;

            try
            {
                jobs = _contentSvc.GetEncodingJobs(encodingSearchCriteria);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, methodName, traceProperties);
                throw;
            }

            Logger.LogTrace("End", methodName, traceProperties);
            return jobs;
谁能告诉我,怎么了,为什么会这样

下面是从Win32服务调用WCF服务的示例代码

            var methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            var traceProperties = new Dictionary<string, object>();
            Logger.LogTrace("Start ", methodName, traceProperties);

            Com.Softechww.Services.ContentInfo.EncodingJobs jobs = null;

            try
            {
                jobs = _contentSvc.GetEncodingJobs(encodingSearchCriteria);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, methodName, traceProperties);
                throw;
            }

            Logger.LogTrace("End", methodName, traceProperties);
            return jobs;

当由于嵌套函数调用过多而耗尽堆栈空间时,会发生StackOverflowException。一个明显的检查是看您是否正在进行任何递归调用。不,它只是在调用WCF方法,没有递归调用。发布GetEncodingJobs的代码-您可能会遇到递归或无限循环的情况。