Microsoft.Office.Interop.Excel.Application when i debug its not given error when i Releas its given error are you missing assembly

Hiteshkumar Patel 21 Reputation points
2022-02-12T09:40:49.767+00:00

hello everyone,
i am trying to Release my Windows base application for automatic update get my application users but its given me an error for
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Excel' does not exist in the namespace 'Microsoft.Office.Interop' (are you missing an assembly reference?) ERPs

when i select Debug mode its not given any error

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,937 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,728 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,161 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,421 Reputation points
    2022-02-12T10:41:58.987+00:00

    Generally when Excel code works in debug mode or release mode on a developer's box then fails on a client's box means either the client does not have Excel installed or does not have the correct version of Excel.

    The best solution is not to use Excel automation, instead use an Excel library which is not dependent on Excel being installed. Two of many free libraries

    https://github.com/ClosedXML/ClosedXML

    https://spreadsheetlight.com/

    And there are plenty of paid for libraries such as

    https://www.gemboxsoftware.com/

    And there is always the option to skip libraries and code what those libraries do yourself

    https://social.technet.microsoft.com/wiki/contents/articles/51328.excel-operations-with-open-xml-automation-and-oledb.aspx

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.