user3215251
user3215251

Reputation: 249

Including References for Installation

I have a C# program that references a few things, namely Excel and office references. However, on the target machine, Office isn't installed. Is there a way to include the reference/dlls that the program needs in some sort of installation package so that it will work?

Here is the error code I get when I try to run it on someone's machine with Excel 2003. I installed the 2010 Interop from microsoft, but this still happened:

Thread failed to Initialize. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The locaved assembly's manifest definition does not match the assembly reference. (Exception from HRESULT:0x80131040)

WRN: Assembly binding logging is turned OFF

It references this section when the error comes up, and despite being on another computer, it shows a path on my computer where the project is located.

private void bgwFirstProcessThread_DoWork(object sender, DoWorkEventArgs e)
    {
        try
        {
            BackgroundWorker worker;
            worker = (BackgroundWorker)sender;

            //Get the Class object and call the main method
            XlsxThread WO = (XlsxThread)e.Argument;
            WO.ProcessXlsx(worker, e);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Thread failed to Initialize.\n" + ex.ToString());
        }
    }

Upvotes: 0

Views: 783

Answers (1)

dhalsumit
dhalsumit

Reputation: 143

Checkout Microsoft Office Primary Interop Assemblies Redistributable available here.. http://www.microsoft.com/en-us/download/details.aspx?id=3508

This allows you to package Microsoft.Office.Interop assemblies (within bin folder) and reference in code.

But if the functionality in code requires MS Office on target machine, the office installation is a must for desired result.

= And AFAIK - if you want to keep it compatible for multiple office versions, you must include the Interop Assembly of the lowest version you want to support to keep your code compatible for all versions. So you will need Excel 2003 compatible interop assembly version for your need http://www.microsoft.com/en-gb/download/details.aspx?id=20923 And that will limit you from using newer office functionalists such as ribbon menu.

Upvotes: 1

Related Questions