HI
Iam created project in visual studio 2008,and once I compile coding,it give me error meassagee.The Error Meassage is

Error 1 The type 'Microsoft.Office.Interop.Excel.Workbook' exists in both 'c:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll' and 'e:\Test\Test\Test\obj\Release\Interop.Microsoft.Office.Interop.Excel.dll'
E:\Test\Test\Test\ 13 67 Test


So what I did is I delete the Excel.dll in (\obj\Release\Interop.Microsoft\Excell.Dll,but once I complie it make a Interop.Microsoft.Office.Interop.Excel.dll' automatically.How to stop this error.


Thanks
Tank50

Dani AI

Generated

A short technical explanation and some practical steps that complement ’s reply.

The root cause is a duplicate set of interop types: Visual Studio can generate a local Interop assembly for a COM reference while Office’s Primary Interop Assemblies (PIAs) are already registered in the Global Assembly Cache (GAC). The compiler then sees the same types twice and reports a conflict.

Practical cleanup and prevention steps:

  • Remove any manually added Interop DLL file from the project references and from the project folder (do not keep a physical Interop.*.dll in the project).
  • Clean the solution and delete the bin and obj folders so stale interop files are gone.
  • Re-add the Excel reference using the Visual Studio References dialog (COM tab or .NET/COM entry) so VS manages the interop correctly.
  • If Office PIAs are present on the machine, set the reference property Copy Local = False so the PIA isn’t copied to output and duplicates aren’t produced.
  • In multi-project solutions, make sure all projects reference the same assembly/version and follow the same Copy Local policy so one project does not reintroduce an interop DLL.

Notes and alternatives: Visual Studio 2010 / .NET 4 introduced embedded interop types (No-PIA) which avoids deploying PIAs — see Microsoft’s guidance on embedded interop types. Automating Excel on a server is unsupported by Microsoft; consult their server-side automation guidance before deploying. For scenarios that don’t require Excel itself, consider managed alternatives (Open XML SDK or libraries like EPPlus/NPOI) to avoid COM interop entirely.

References: , Type equivalence and embedded interop types, .

Recommended Answers

All 2 Replies

Remove it from project references.

Hi

yes your right,I removed it from reference ,now its working

Thanks
Tank50

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.