Skip to content
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 entries when including Office interop #796

Closed
JohnyL opened this issue Dec 12, 2019 · 6 comments
Closed

Incorrect COMReference entries when including Office interop #796

JohnyL opened this issue Dec 12, 2019 · 6 comments

Comments

@JohnyL
Copy link

JohnyL commented Dec 12, 2019

To include Excel interop libraries, I do the following: Dependencies -> Add Reference -> COM -> Microsoft Excel 14.0 Object Library. When I do this, I get the following ItemGroup:

<ItemGroup>
    <COMReference Include="Microsoft.Office.Excel.dll">
        <Guid>00020813-0000-0000-c000-000000000046</Guid>
        <VersionMajor>1</VersionMajor>
        <VersionMinor>7</VersionMinor>
        <WrapperTool>tlbimp</WrapperTool>
        <Lcid>0</Lcid>
        <Isolated>false</Isolated>
    </COMReference>
</ItemGroup>

However, I get the following error:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified.

In order to work, I have created .NET Framework app, added COM reference there and copied its COMReference - and it works:

<ItemGroup>
    <COMReference Include="Microsoft.Office.Interop.Excel">
        <Guid>{00020813-0000-0000-C000-000000000046}</Guid>
        <VersionMajor>1</VersionMajor>
	<VersionMinor>7</VersionMinor>
	<Lcid>0</Lcid>
	<WrapperTool>primary</WrapperTool>
	<Isolated>False</Isolated>
	<EmbedInteropTypes>True</EmbedInteropTypes>
    </COMReference>
</ItemGroup>
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Dec 12, 2019
@AaronRobinsonMSFT
Copy link
Member

@JohnyL Is this a run time or build time error? It seems like a run time error and is because of the missing types. The fix would be to deploy the PIA or add the <EmbedInteropTypes>True</EmbedInteropTypes>.

@JohnyL
Copy link
Author

JohnyL commented Dec 13, 2019

@AaronRobinsonMSFT Yes, it's run time error. Adding <EmbedInteropTypes>True</EmbedInteropTypes> did work! This means that this COMReference lacks this entry.

@AaronRobinsonMSFT
Copy link
Member

AaronRobinsonMSFT commented Dec 13, 2019

@rainersigwald I don't have access to the MSBuild repo, but I think this work might need to happen there. I believe that contains the logic for adding the ComReference node? This might actually be in the VS side of things, but I am not entirely sure.

@Pilchie Does VS handle the updating of the .csproj file when adding a COM reference? If so, would it be possible to move this issue to a VS repo or should I create an internal issue for defaulting to EmbedInteropTypes when adding a COM reference to a .NET Core project?

@Pilchie
Copy link
Member

Pilchie commented Dec 13, 2019

I'm not on the project system team anymore, so tagging @jjmew, but you can use https://github.com/dotnet/project-system for issues there.

@drewnoakes
Copy link
Member

This can be closed in lieu of dotnet/project-system#5735

@AaronRobinsonMSFT
Copy link
Member

@drewnoakes Thanks!

@AaronRobinsonMSFT AaronRobinsonMSFT removed the untriaged New issue has not been triaged by the area owner label Dec 16, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants