C# windows应用程序“SubSonic.SqlQuery.ExecuteAsCollection[ListType]()”中出错

C# windows应用程序“SubSonic.SqlQuery.ExecuteAsCollection[ListType]()”中出错,c#,winforms,subsonic,C#,Winforms,Subsonic,我在windows服务器2012x64中运行windows applicationx86平台,并使用亚音速从SQLserver获取数据 我从try-catch异常中得到了这个错误 位于SubSonic.SqlQuery.ExecuteAsCollectionListType处 位于的CIS.Server.Automailer.Core.ReportConfig.getReportConfig CIS.Server.Automailer.Automailer.process下载地址 CIS.Ser

我在windows服务器2012x64中运行windows applicationx86平台,并使用亚音速从SQLserver获取数据

我从try-catch异常中得到了这个错误

位于SubSonic.SqlQuery.ExecuteAsCollectionListType处 位于的CIS.Server.Automailer.Core.ReportConfig.getReportConfig CIS.Server.Automailer.Automailer.process下载地址 CIS.Server.Automailer.Program.Main

以下是我的源代码:

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;

    namespace CIS.Server.Automailer
    {
        static class Program
        {
            [STAThread]
            static void Main()
            {
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    Automailer mailer = new Automailer();
                    mailer.processDownload();

                    Application.Run();
                }
                catch(Exception ex)
                {
                    Log(ex);
                }

            }

            static void Log(Exception ex)
            {
                string stackTrace = ex.StackTrace;
                File.WriteAllText("trace.txt", stackTrace); // path of file where stack trace will be stored.
            }
        }
    }
汽车制造商

public void processDownload()
    {
        var data = ReportConfig.getReportConfig();
        var machineCenterIds = data[0].MachineCenterId;
        var reportIds = data[0].ReportId;
        var email = data[0].Email;

        recipient = email;
        string[] splitRepId = reportIds.Split(',');
        int[] repIds = new int[splitRepId.Length];
        int c=0;
        foreach (string repId in splitRepId)
        {
            repIds[c] = Convert.ToInt32(repId);
            c++;
        }
        var reportNames = ReportConfig.getReportName(repIds);
        string[] splitMcIds = machineCenterIds.Split(',');

        int ctr = 0;
        filePaths = new string[splitMcIds.Length * reportNames.Count()];

        ei.processFinished = false;
        foreach (string mcId in splitMcIds)
        {
            for (int i = 0; i < reportNames.Count(); i++)
            {
                string reportName = Convert.ToString(reportNames[i]);
                string url = Utility.GetTemporaryURL(mcId, reportName);
                string fileName = reportName.Replace(" ", "");// + "_" + j + "_00" + i
                downloadPath = string.Format(configPath, mcId, fileName);
                filePaths[ctr] = downloadPath;
                GenerateMails(url);
                Console.WriteLine(downloadPath);
                ctr++;
            }
        }
        processEmail();
        ei.processFinished = true;
    }
ReportConfig.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CIS.Server.Automailer.Core
{
    class ReportConfig
    {
        public static ReportAutomationCollection getReportConfig()
        {      
            return DB.Select().From(ReportAutomation.Schema)
                    .Where(ReportAutomation.Columns.UserId).IsEqualTo("001111d6-cc2a-469a-a1bc-1ccd64e60a08")
                    .ExecuteAsCollection<ReportAutomationCollection>();
        }

        public static ReportTypeCollection getReportName(int[] reportId)
        {
            return DB.Select(ReportType.Columns.ReportName).From(ReportType.Schema)
                                .Where(ReportType.ReportIdColumn).In(reportId.ToString())
                                .ExecuteAsCollection<ReportTypeCollection>();
        }

    }
}

看起来你的数据库有问题。因为您现在的访问权限在服务器上

如果本地和服务器上都存在数据,请检查数据


您是否在getReportConfig中设置了断点?顺便问一下,此应用程序在我的工作站32位pc中工作时,仅当我尝试在windows server 2012x64中运行时才会发生此错误。这里没有太多信息,但我感觉您的括号放错了位置。但是我完全调试了这个程序,并安装在我的工作站上,它工作正常。问题是,在我将程序安装到windows server 2012x64并尝试运行后,应用程序正在任务管理器中处理,但在使用SubSonic进行查询后将终止。您是在两台机器上使用完全相同的数据库,还是有测试和生产数据库?另外,其余的异常详细信息是什么?你知道了Dyrandz,我发现错误是查找服务器上不存在的数据。