【问题标题】:Build Error with External Assembly in .NET6 Blazor Webassembly App在 .NET6 Blazor Webassembly 应用程序中使用外部程序集生成错误
【发布时间】:2021-09-22 03:54:47
【问题描述】:

我正在尝试使用 Visual Studio 2022(预览版)使用 .Net6 创建 Blazor Webassembly 应用程序。我已经在该项目中引用了外部程序集文件。当我构建项目时,出现以下错误,

在任何搜索到的位置“D:\Office\Testing\BlazorApp1”中都找不到资产“D:\Office\Testing\BlazorApp1\BlazorApp1\bin\Debug\net6.0\wwwroot_framework\ClassLibrary1.dll” \BlazorApp1\bin\Debug\net6.0\wwwroot_framework\ClassLibrary1.dll'和'ClassLibrary1'

screen shot image

有解决办法吗?

此处的项目属性

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.1.21452.15" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="ClassLibrary1">
      <HintPath>Lib\ClassLibrary1.dll</HintPath>
      <EmbedInteropTypes></EmbedInteropTypes>
    </Reference>
  </ItemGroup>

  <ItemGroup>
    <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
  </ItemGroup>

</Project>

【问题讨论】:

  • 将问题中的文本作为文本而不是图像。
  • 错误不在发布的代码中。将错误作为文本发布。
  • 但 'Office' 和 EmbedInteropTypes 暗示在浏览器中无法正常工作。
  • @HenkHolterman,我编辑了这个问题。
  • “作为文本”只是一般规则。发布的代码看起来不错,错误确实在其他地方。文件会在那里复制吗?等

标签: c# visual-studio blazor-webassembly .net-6.0


【解决方案1】:

你只需要改变这个,

<ItemGroup>
   <Reference Include="../Lib/ClassLibrary1">
     <HintPath>Lib\ClassLibrary1.dll</HintPath>
     <EmbedInteropTypes></EmbedInteropTypes>
   </Reference>   
</ItemGroup>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-06
    • 1970-01-01
    • 2021-07-24
    • 1970-01-01
    • 2021-06-21
    • 2021-10-26
    • 2021-06-28
    • 1970-01-01
    相关资源
    最近更新 更多