application crash export to excel to excel 2013 RRS feed

  • Question

  • everything is working perfect in Office 2007. but failing in office 2013.

    Error is : Could not load file or assembly Microsoft.Office.Interop.Excel

    how to resolve it with out changing my code.

    I want a solution working for both Office 2013 and 2007

    Thanks in advance

    Thursday, January 2, 2014 2:18 PM


  • Hello Rosh,

    It looks like you forget to include to the installer or just copy to the target computer with Office 2013 the mentioned in the error message assembly (Microsoft.Office.Interop.Excel.dll). Is this the case?

    There are two ways for your application to include the type information that enables interoperation with COM types:

    • Using embedded interop types: Beginning with the .NET Framework 4, you can instruct the compiler to embed type information from an interop assembly into your executable. The compiler embeds only the type information that your application uses. You do not have to deploy the interop assembly with your application. This is the recommended technique.

    • Deploying interop assemblies: You can create a standard reference to an interop assembly. In this case, the interop assembly must be deployed with your application. If you employ this technique, and you are not using a private COM component, always reference the primary interop assembly (PIA) published by the author of the COM component you intend to incorporate in your managed code. For more information about producing and using primary interop assemblies, see Primary Interop Assemblies.

    So, to avoid such error messages you can set the Embed Interop Types property of the reference (see the Reference folder of your project in the Solution Explorer window) to true and don't include the interop library to the installation package.

    Thursday, January 2, 2014 3:16 PM