首页 > 解决方案 > 如何在 Dot net core 项目中添加 COM 引用

问题描述

我正在使用 Visual Studio 2019 将 COM 引用添加到另一个项目。但我无法添加参考。出现以下错误:

在此处输入图像描述

即使我已经创建了一个 COM.dll 文件并成功注册了 COM.comhost.dll 文件,但我无法解决的问题。

COM.csproj 文件

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!--<OutputType>Exe</OutputType>-->
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <EnableComHosting>True</EnableComHosting>
    <EnableRegFreeCom Condition="'$(RegFree)' == 'True'">True</EnableRegFreeCom>
  </PropertyGroup>
  <Target Name="ServerUsage"
           Condition="'$(RegFree)' != 'True'"
           AfterTargets="Build">
    <Message Importance="High" Text="%0a************************************%0a*** $(MSBuildProjectName) usage instructions ***%0a************************************" />
    <Message Importance="High" Text="The server must be COM registered in order to activate.%0aThe following commands must be executed from an elevated command prompt." />
    <Message Importance="High" Text="Register:%0a    regsvr32.exe &quot;$(ProjectDir)$(OutputPath)$(ComHostFileName)&quot;" />
    <!--<Message Importance="High" Text="Unregister:%0a    regsvr32.exe /u &quot;$(ProjectDir)$(OutputPath)$(ComHostFileName)&quot;" />-->
  </Target>
</Project>

标签: c#.netasp.net-corec#-4.0com

解决方案


推荐阅读