Our Net6 application uses Excel Interop via COMReference in the csproj file.
<COMReference Include="Microsoft.Office.Interop.Excel">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>9</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>00020813-0000-0000-c000-000000000046</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
<CopyLocal>true</CopyLocal>
</COMReference>
This works, embedding the required subset of interop types in the Net6 assembly.
However, if I set EmbedInteropTypes to false, msbuild copies a couple of Net Framework assemblies to the bin folder. These assemblies themselves reference stdole
and Microsoft.Vbe.Interop
from the GAC.
Are these Net4, Net2 (Vbe), and Net1 (stdole) assemblies safe for use in a Net6-windows application? Things seem to work locally, but I'm concerned that it may be a bit flakey and not work in other environments.
If a user has a (current) Windows OS and Office installed, will they also have these assemblies in the GAC? Or should I distribute stdole and the Vbe assembly with my application?
[The reason I want to consider disabling embedding is that our obfuscation tool mangles the embedded interop types if it merges two assemblies that have them.]
Another question: Why are embedded interop types not visible to other assemblies that reference the one containing the embedded types? Is there a way to make them available outside the containing assembly?