【问题标题】:Program using LinqToExcel works on my computer but after publishing and installation on another one it does not使用 LinqToExcel 的程序可以在我的计算机上运行,​​但在另一台计算机上发布和安装后,它不能
【发布时间】:2019-05-24 11:20:16
【问题描述】:

使用 LinqToExcel 发布和安装的程序会引发“调用目标已引发异常”异常。内部异常不显示,但在我的计算机上,如果我单独运行 exe 文件而没有其他源文件,则无法加载文件或程序集 linqtoexcel。但是当我尝试单独运行它时,它只在我的电脑上。但我相信它是相似的?

两台电脑都是Win10,都安装了Access DB Engine 64bits or 64bits Offices。

public void ImportNewData(String file) 
    {

    ExcelConnector excel = new ExcelConnector(file);

    foreach(var result in excel.ReadNewData()) 
    {
        this.loopsList.Add((Loop) result);
    }
}

public IEnumerable ReadNewData() {
    try 
    {
        var query = from a in this.ExcelConnection.Worksheet < Loop > ("Data")
        select a;

        return query;
    } 
    catch (Exception exeption) 
    {
        MessageBox.Show(exeption.Message + "\n" + exeption.InnerException.Message + "\n" + exeption.InnerException.Source, "Warning");
        return null;
    }

}

我希望它可以在任何 Windows 机器上运行 :)

【问题讨论】:

  • 两台机器是否安装了相同版本的 Excel?
  • 不,我有 Excel 2016,我的同事有 Excel 2013。另外我有 32 位办公室,他有 64 位...
  • 查看docs,您需要执行以下操作 - 为了使用 LinqToExcel,您需要安装 Microsoft Microsoft Access Database Engine 2010 Redistributable。
  • 拥有不同版本的 excel 可能会导致问题,但我首先要确保两台电脑都安装了 Microsoft Access Database Engine 2010 Redistributable。
  • 在装有 64 位 Office 的机器上...确保它们具有 Microsoft Access Database Engine 2010 Redistributable 的 64 位。

标签: c# visual-studio linq publish linq-to-excel


【解决方案1】:

我取消选中此复选框,现在它也适用于 64 位 Office。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-21
    • 2020-06-26
    • 2011-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多