【问题标题】:Error in windows application "SubSonic.SqlQuery.ExecuteAsCollection[ListType]()"Windows 应用程序“SubSonic.SqlQuery.ExecuteAsCollection[ListType]()”中的错误
【发布时间】:2015-02-11 07:17:20
【问题描述】:

我在 windows server 2012(x64) 中运行 windows 应用程序 (x86) 平台,并且正在使用 SubSonic 从 SQLserver 获取数据。

我从 try catch Exception 得到了这个错误

在 SubSonic.SqlQuery.ExecuteAsCollectionListType 处 CIS.Server.Automailer.Core.ReportConfig.getReportConfig() 在 CIS.Server.Automailer.Automailer.processDownload() 在 CIS.Server.Automailer.Program.Main()

这是我的源代码:

程序.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.
            }
        }
    }

Automailer.cs

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 位电脑)上运行,这个错误只发生在我尝试在 windows server 2012(x64) 中运行时。
  • 嗯,这里没有太多信息可以继续,我感觉你的括号放错了地方.......UserId).IsEqualTo
  • 但是我完全调试了程序并安装在我的工作站上,它工作正常。问题是,在我在 windows server 2012(x64) 中安装程序并尝试运行后,应用程序正在任务管理器中处理,但我认为它会在使用 SubSonic 查询后终止。
  • 你是在两台机器上使用完全相同的数据库,还是你有一个测试和生产数据库?另外,其余的异常详细信息是什么?

标签: c# winforms subsonic


【解决方案1】:

您的database 似乎有问题。因为您现在的访问权限在服务器上。

检查您的数据是否同时存在于您的本地和服务器上。

【讨论】:

  • 你知道了 Dyrandz,我发现错误是在寻找服务器上不存在的数据。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 2017-09-11
  • 2013-03-27
  • 1970-01-01
相关资源
最近更新 更多