When I faced a similar problem I created a NuGet package with the following structure.
The MYCOMLib.dll is a interop DLL generated from the mycom.dll with the Type Library Importer (tlbimp.exe).
This is simply done with the command :
Tlbimp mycom.dll
The install.ps1 contains the following code:
param($installPath, $toolsPath, $package, $project)
regsvr32 Join-Path $toolsPath 'mycom.dll' /s
$project.Object.References | Where-Object { $_.Name -eq "MYCOMLib" } | ForEach-Object { $_.EmbedInteropTypes = $false }
What this script does is that it registers the COM dll and sets the EmbedInteropTypes property on the reference to false, which is necessary when using .NET 4. See Interop type cannot be embedded for more information.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…