新的.NET Core SDK项目类型-无法调试COM加载项?

我最近在旧项目上升级到.NET Framework 4.8,并认为我发现了Visual Studio 2019调试器和/或新的.NET Core SDK项目类型的局限性。

以下是csproj的前后:

之前

ExcelAddin.MyRtdServer.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">anycpu</Platform>
    <ProjectGuid>{572DAC9C-DC52-425A-83F2-6EF0EB4FF2BC}</ProjectGuid>
    <OutputType>library</OutputType>
    <AssemblyName>ExcelAddin.MyExcelRtdServer</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <ApplicationVersion>1.0.0.0</ApplicationVersion>
    <FileAlignment>512</FileAlignment>
    <RootNamespace>ExcelAddin.MyExcelRtdServer</RootNamespace>
    <FileUpgradeflags>
    </FileUpgradeflags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>3.5</OldToolsVersion>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|anycpu' ">
    <PlatformTarget>anycpu</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
    <RegisterForComInterop>true</RegisterForComInterop>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
    <PlatformTarget>anycpu</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup>
    <SignAssembly>true</SignAssembly>
  </PropertyGroup>
  <PropertyGroup>
    <AssemblyOriginatorKeyFile>MyStrongName.snk</AssemblyOriginatorKeyFile>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="microsoft.Office.Interop.Excel,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c,processorArchitecture=MSIL">
      <HintPath>..\packages\microsoft.Office.Interop.Excel.15.0.4795.1000\lib\net20\microsoft.Office.Interop.Excel.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Data.Linq" />
    <Reference Include="System.Data" />
    <Reference Include="System.Core" />
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\GlobalAssemblyInfo.cs">
      <Link>Properties\GlobalAssemblyInfo.cs</Link>
    </Compile>
    <Compile Include="MyRtdServer.cs" />
    <Compile Include="Properties\Settings.Designer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
    <None Include="packages.config" />
    <None Include="MyStrongName.snk" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\microsoft.CSharp.targets" />
</Project>

ExcelAddin.MyRtdServer.csproj.user

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|anycpu'">
    <Startaction>Program</Startaction>
    <StartProgram>C:\Program Files %28x86%29\microsoft Office\root\Office16\EXCEL.EXE</StartProgram>
  </PropertyGroup>
  <PropertyGroup>
    <ProjectView>ShowAllFiles</ProjectView>
  </PropertyGroup>
</Project>

之后

ExcelAddin.MyRtdServer.csproj

<Project Sdk="microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <PropertyGroup>
    <Authors>John Zabroski</Authors>
    <Description>ExcelAddin.MyExcelRtdServer .NET Assembly</Description>
    <Copyright>Copyright © 2019</Copyright>
    <SignAssembly>true</SignAssembly>
    <AssemblyOriginatorKeyFile>MyStrongName.snk</AssemblyOriginatorKeyFile>
  </PropertyGroup>
  <ItemGroup>
    <None Remove="appSettings.xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="appSettings.xml">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Configuration" />
    <Reference Include="System.Data.Linq" />
  </ItemGroup>
</Project>

launchSettings.json

{
  "profiles": {
    "ExcelAddin.MyRtdServer": {
      "commandName": "Executable","executablePath": "C:\\Program Files (x86)\\microsoft Office\\root\\Office16\\EXCEL.EXE"
    }
  }
}
gukoule 回答:新的.NET Core SDK项目类型-无法调试COM加载项?

Excel-DNA目前不支持新的SDK样式的项目,我们正在努力添加对即将发布的Excel-DNA版本的支持。

您可以跟踪以下问题以获取有关该方面进展的通知:

本文链接:https://www.f2er.com/3099889.html

大家都在问