c# - 如何在 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 "$(ProjectDir)$(OutputPath)$(ComHostFileName)"" />
<!--<Message Importance="High" Text="Unregister:%0a regsvr32.exe /u "$(ProjectDir)$(OutputPath)$(ComHostFileName)"" />-->
</Target>
</Project>
解决方案
推荐阅读
- r - 将插入符号的混淆矩阵应用于由 data.frames 组成的列表,从而产生多个混淆矩阵
- javascript - 来自“动态”数据 JSON 值的多折线图
- python - 使用 Pandas 比较字符串到 JSON
- php - 如何以 www-data 的身份向其他用户发送 sudo 或 su
- database - 谁能从欧文模型中解释这些符号?
- ios - viewController 在我关闭它时出现
- dataframe - Saving Spark DataFrame created from an oracle query in a hive table?
- c - 为什么 get_long_long("") 打印 2 次?
- php - 尝试连接时出现“SQLSTATE [HY000] [2006] MySQL 服务器已消失”
- elasticsearch - 预测最优 ElasticSearch Query-time Boost 值的深度学习模型