Error "Interop type cannot be embedded" in C# when working with COM
Hello! I'm a beginner in C# and trying to connect to Excel via COM objects. I have Visual Studio 2010, .NET Framework 4.0 project.
I added a reference to the Microsoft.Office.Interop.Excel library through the COM tab in References. Wrote a simple code:
```csharp
using Excel = Microsoft.Office.Interop.Excel;
class Program
{
static void Main()
{
var excelApp = new Excel.Application();
excelApp.Visible = true;
excelApp.Quit();
}
}
```
When compiling I get the error:
"Interop type 'Microsoft.Office.Interop.Excel.ApplicationClass' cannot be embedded. Use the applicable interface instead."
I googled it but didn't understand anything. Why does this error occur? What does "cannot be embedded" mean? And how to fix it? I just need to open Excel and write data to a
No answers yet.
Log in to leave an answer
Blogs
GraphQL API with Java: Step-by-Step Practical Tutorial
Event-driven Architecture in Kotlin: From Coroutines to Reactive Streams
Documentation in Java: How to Write Code That Speaks for Itself
OAuth 2.0 and JWT Authorization in Swift: A Step-by-Step Guide for Beginners