Aspnetcore: Error "Assembly paths must be rooted" when referencing COM

Created on 4 May 2020  路  4Comments  路  Source: dotnet/aspnetcore

Describe the bug

Including a reference to a COM object causes the first build to fail while the subsequent build succeeds.

Error The assembly path obj\Debug\netcoreapp3.1\Interop.{0}.dll is invalid. Assembly paths must be rooted. {1} C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets 99

To Reproduce

Include a COM library reference to a ASP.NET Core project.

This issue has been referenced multiple times and has not been resolved.

There is a workaround described in this issue but it's far from ideal. This referenced issue also includes a sample project with the bug.
https://github.com/dotnet/aspnetcore/issues/5086

Second reference to the bug.
https://developercommunity.visualstudio.com/content/problem/899081/error-assembly-paths-must-be-rooted-when-referenci.html

Further technical details

  • ASP.NET Core 3.1.3
  • Visual Studio 2019 16.4.3
affected-few area-mvc bug investigate severity-major

Most helpful comment

This repo demonstrates the problem.
https://github.com/tenacioustechie/ATEM-TallyLights

The COM library I'm referecing is the blackmagic ATEM switcher software & sdk
https://www.blackmagicdesign.com/au/support/family/atem-live-production-switchers

All 4 comments

This repo demonstrates the problem.
https://github.com/tenacioustechie/ATEM-TallyLights

The COM library I'm referecing is the blackmagic ATEM switcher software & sdk
https://www.blackmagicdesign.com/au/support/family/atem-live-production-switchers

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

I think I am posting this too in my website blog but I have only found an ugly workaround:

  1. Create a new project using the .NET Core Class Library template (I usually call it COMRefs).
  2. Add your COM References to this library. Do not add any code, just build.
  3. Take the Compiled Interop.* Libraries for example bin\Debug\netcoreapp3.1\Interop.CDO.dll and Interop.ADODB.dll and copy them to a Libs folder.
  4. Now Right click your Web Application. Select Add COM Reference but now use the browse option and add the files from the Lib folder.
    Remember that you .NET Core Web App must be set to x86 or x64 depending on your reference.
    Now you can build and run
Was this page helpful?
0 / 5 - 0 ratings

Related issues

groogiam picture groogiam  路  3Comments

aurokk picture aurokk  路  3Comments

markrendle picture markrendle  路  3Comments

TanvirArjel picture TanvirArjel  路  3Comments

FourLeafClover picture FourLeafClover  路  3Comments