Could not load file or assembly 'Interop.Office, Version=2.1.0.0,'

466 views Asked by At

I'm using .NET version 3.5, while i'm uploading data into Oracle database from .xls files using C#.NET getting below error:

Exception System.IO.FileNotFoundException

Error Message Could not load file or assembly 'Interop.Office, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file.

Stacktrace

at FileHelpers.DataLink.ExcelStorage.CloseAndCleanUp() at FileHelpers.DataLink.ExcelStorage.ExtractRecords() at "......"

i have tried with interop.office version=2.1.0.0 .dll, even getting same error.

1

There are 1 answers

17
Eugene Astafiev On

Exception System.IO.FileNotFoundException

Error Message Could not load file or assembly 'Interop.Office, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file.

The exception says that the Interop.Office.dll file is missing on the computer. You need to include it to the installer.

However, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

Consider using third-party components designed for the server-side execution. Also if you consider dealing with open XML spreadsheets (.xslx) you may also consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information.