-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect COMReference entry when using Office interop #5735
Comments
Repro steps:
netcoreapp3.1 <ItemGroup>
<COMReference Include="Microsoft.Office.Excel.dll">
<Guid>00020813-0000-0000-c000-000000000046</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>9</VersionMinor>
<WrapperTool>tlbimp</WrapperTool>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
</COMReference>
</ItemGroup> net471 <ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>8</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="Microsoft.Office.Interop.Excel">
<Guid>{00020813-0000-0000-C000-000000000046}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>9</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="VBIDE">
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
<VersionMajor>5</VersionMajor>
<VersionMinor>3</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup> |
Beg your pardon - I forgot to mention that this happens in .NET Core. |
I have found out that if you use |
I'm hitting this, just as above, in Sept of 2020. @davkean Seems like you can't do Office Interop with Core unless you do the com reference manually? Tooling does this (wrong:)
Correct:
|
@shanselman Your correct variant is correct. 😉 This is what COMReference should have:
|
As per a chat with @shanselman this is popping up in multiple places: dotnet/msbuild#4332 Is the root problem the VS tooling or the MSBuild issue? |
This is a CPS bug, we should get a Developer feedback item filed and moved to them. |
@JohnyL, @shanselman: I've investigated and established several issues at this point:
We're going to fix 1 & 2 in the project system (though 1 is minor as the |
For .NET Core 3.1 projects, you can workaround the problem with .NET 5 projects do not seem to have the same issue. |
Also encountered this. The solution mentioned here works, except for I just upgraded to .NET 5.0. |
It's April 2021, using .Net 5 and the problem still exists. I just used the solution in @shanselman's post to work on Excel. For quick reference:
Are there any plans to fix this in the tooling? |
I had same issue using .net5 and .net6 But now I can use excel when using .net5/6
|
@ULTRAKKK1004 Beg your pardon, but understood nothing what you were trying to say. |
@JohnyL check url below. You are making winform app using .net core, Right? Just add Excel.exe file to Reference. |
@ULTRAKKK1004 |
@JohnyL I tested vs2022/vs2019, c#, .net core3.1, winform/console. |
@JohnyL |
@ashwiniuchit |
March 2024, There is my solution (net core 7, Excel v16):
Its works, in Win 64 bits. |
@shanselman while the COMReference works fine for my local build machine, it breaks when Excel is not installed, which is the case for our CI machines in Azure Devops. How can we achieve to build this correctly, given that its impossible to install Office/Excel on those agents? Thanks for any insights :) |
To include Excel interop libraries in .NET Core app, I do the following:
Dependencies -> Add Reference -> COM -> Microsoft Excel 14.0 Object Library
. When I do this, I get the followingItemGroup
:However, I get the following runtime error:
In order to work, I have created .NET Framework app, added COM reference there and copied its COMReference - and it works:
As noted here, in order to fix the situation, the project system needs to add
<EmbedInteropTypes>True</EmbedInteropTypes>
.The text was updated successfully, but these errors were encountered: