1

Published and installed program using LinqToExcel throws an "Exception has been thrown by the target of an invocation" exception. Inner exeption is not displayed but on my computer if I run exe file separately w/o another source files there is Could not load file or assembly linqtoexcel. but it is only on my PC when I tried to run it separately. But I beleave it is similar?

Both PCs are Win10, Access DB Engine 64bits or 64bits Offices are installed.

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;
    }

}

I expect it will run on any Windows machine :)

Thaoden
  • 3,460
  • 3
  • 33
  • 45
Jan Daliba
  • 29
  • 5
  • Do both machines have the same version of Excel installed? – Tony Abrams May 24 '19 at 11:23
  • No, I have Excel 2016 and my colleage has Excel 2013. Also I have 32bit office and he has 64bit... – Jan Daliba May 24 '19 at 11:25
  • Looking at the [docs](https://github.com/paulyoder/LinqToExcel), you need to do the following - In order to use LinqToExcel, you need to install the Microsoft Microsoft Access Database Engine 2010 Redistributable. – Tony Abrams May 24 '19 at 11:26
  • Having different version of excel could cause a problem, but I would start with making sure both pc's have the Microsoft Access Database Engine 2010 Redistributable installed. – Tony Abrams May 24 '19 at 11:27
  • Thank you. But it does not helped. On my another colleague PC with Office 32bit and this Engine at also work. Only with 64bits office there is a trouble even with full Access... Maybe this Engine in 32bit version? But I thought it should be in system by default... – Jan Daliba May 24 '19 at 11:36
  • 1
    On the machine with the 64bit Office ... make sure they have the 64bit of the Microsoft Access Database Engine 2010 Redistributable. – Tony Abrams May 24 '19 at 11:39
  • If you have full Access 64bit you also need this database engine? I thought it is neccessary when you do not have Access itself... But I will try, thank you – Jan Daliba May 24 '19 at 11:56

1 Answers1

0

I unchecked this check box and now it works also with 64bit Office.

32

Jan Daliba
  • 29
  • 5