简体   繁体   English

System.Windows.Forms 的许可错误,版本=6.0.2.0?

[英]Licensing error with System.Windows.Forms, Version=6.0.2.0?

I am getting some really weird errors relocating a project over to a new pc.我遇到了一些非常奇怪的错误,将项目重新定位到新电脑上。 I am using VS 2022 with.NET Core 6. The error on the newer pc is as follows:我正在使用 VS 2022 with.NET Core 6。较新的 pc 上的错误如下:

LC: error LC0000: 'Could not load file or assembly 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. LC:错误 LC0000:“无法加载文件或程序集‘System.Windows.Forms,Version=6.0.2.0,Culture=neutral,PublicKeyToken=b77a5c561934e089’或其依赖项之一。 Reference assemblies should not be loaded for execution.不应为执行加载引用程序集。 They can only be loaded in the Reflection-only loader context.它们只能在仅反射加载器上下文中加载。 (Exception from HRESULT: 0x80131058)' (HRESULT 异常:0x80131058)'

I thought maybe one of my 3rd party controls could be causing this so I removed ALL of them and I still got the same error.我想也许我的第 3 方控件之一可能导致此问题,所以我删除了所有控件,但我仍然遇到相同的错误。

So I decided on the newer pc to start a new.NET Core 6 project and it compiles and runs just fine with the same System.Windows.Forms reference.所以我决定在较新的 pc 上启动一个新的 .NET Core 6 项目,它使用相同的 System.Windows.Forms 参考编译和运行得很好。 I even went into my solution explorer and drilled down into my references to compare the broken project with the fresh brand new one.我什至进入我的解决方案资源管理器并深入研究我的参考资料,将损坏的项目与全新的项目进行比较。 Both use the same.dll with the versions matching exactly.两者都使用相同的 .dll,版本完全匹配。

I've nuked my bin folder and have tried several other things to no avail.我已经核对了我的 bin 文件夹并尝试了其他几种方法但无济于事。 I noticed it says the error is "LC" which I googled and found that has to do with licensing?我注意到它说错误是“LC”,我用谷歌搜索发现它与许可有关? I don't really have any knowledge on that subject.我真的没有关于那个主题的任何知识。 Has anybody seen this before or knows what could be the underlying issue?有没有人以前见过这个或知道潜在的问题是什么?

Below is a picture of my do.net --info.下面是我的 do.net --info 的图片。 The blue screen is the working pc and the black is the non-working..蓝屏是工作电脑,黑色是非工作电脑。

Thanks谢谢

在此处输入图像描述

Here is the.vbproj contents of my main project.这是我的主要项目的.vbproj 内容。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <OutputType>WinExe</OutputType>
    <StartupObject>Sub Main</StartupObject>
    <MyType>WindowsForms</MyType>
    <AssemblyVersion>1.0.2202.400</AssemblyVersion>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <UseWindowsForms>true</UseWindowsForms>
    <UseWPF>true</UseWPF>
    <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DocumentationFile>MyPortal.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <PlatformTarget>x64</PlatformTarget>
    <Prefer32Bit>false</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DefineDebug>false</DefineDebug>
    <DocumentationFile>MyPortal.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <PropertyGroup>
    <ApplicationIcon>MyPortal.ico</ApplicationIcon>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <Authors></Authors>
    <PackageIcon>MyPortal.png</PackageIcon>
    <PackageIconUrl />
  </PropertyGroup>
  <ItemGroup>
    <Import Include="System.Drawing" />
    <Import Include="System.Windows.Forms" />
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Classes\cls_DoubleBufferedDGV.vb" />
    <Compile Update="Custom Controls\QuestionCheckbox.Designer.vb">
      <DependentUpon>QuestionCheckbox.vb</DependentUpon>
    </Compile>
    <Compile Update="Custom Controls\QuestionCheckbox.vb">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="Custom Controls\QuestionTextbox.Designer.vb">
      <DependentUpon>QuestionTextbox.vb</DependentUpon>
    </Compile>
    <Compile Update="Custom Controls\QuestionTextbox.vb">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="Custom Controls\QuestionYesNo.Designer.vb">
      <DependentUpon>QuestionYesNo.vb</DependentUpon>
    </Compile>
    <Compile Update="Custom Controls\QuestionYesNo.vb">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="Custom Controls\Callout.Designer.vb">
      <DependentUpon>Callout.vb</DependentUpon>
    </Compile>
    <Compile Update="Custom Controls\Callout.vb">
      <SubType>UserControl</SubType>
    </Compile>
    <Compile Update="frm_ExtendAccounts.designer.vb">
      <DependentUpon>frm_ExtendAccounts.vb</DependentUpon>
    </Compile>
    <Compile Update="frm_PhoneNumbers.designer.vb">
      <DependentUpon>frm_PhoneNumbers.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmAuth.designer.vb">
      <DependentUpon>frmAuth.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmListItemEditor.Designer.vb">
      <DependentUpon>frmListItemEditor.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmListItemPicker.Designer.vb">
      <DependentUpon>frmListItemPicker.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmNewQuestion.designer.vb">
      <DependentUpon>frmNewQuestion.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmPleaseWait.designer.vb">
      <DependentUpon>frmPleaseWait.vb</DependentUpon>
    </Compile>
    <Compile Update="frm_Permissions.designer.vb">
      <DependentUpon>frm_Permissions.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmAutoADSearchbox.designer.vb">
      <DependentUpon>frmAutoADSearchbox.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmLists.Designer.vb">
      <DependentUpon>frmLists.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\frmQuestions.designer.vb">
      <DependentUpon>frmQuestions.vb</DependentUpon>
    </Compile>
    <Compile Update="Generic Forms\Inputbox.Designer.vb">
      <DependentUpon>Inputbox.vb</DependentUpon>
    </Compile>
    <Compile Update="My Project\Application.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Application.myapp</DependentUpon>
      <DesignTime>True</DesignTime>
    </Compile>
    <Compile Update="My Project\Resources.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Update="My Project\Settings.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    <Compile Update="frm_Splash_Startup.Designer.vb">
      <DependentUpon>frm_Splash_Startup.vb</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="My Project\licenses.licx" />
  </ItemGroup>
  <ItemGroup>
    <None Update="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Update="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
    <None Include="..\.editorconfig" Link=".editorconfig" />
    <None Include="Resources\MyPortal.png">
      <Pack>True</Pack>
      <PackagePath>
      </PackagePath>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Content Include="appsettings.json" />
    <Content Include="MyPortal-Icons\MyPortal.ico" />
    <Content Include="MyPortal-Icons\MyPortal.png" />
    <Content Include="MyPortal-Icons\MyPortal_TestBranch.ico" />
    <Content Include="MyPortal-Icons\MyPortal_TestBranch.png" />
    <Content Include="Notes\Notes.txt" />
    <Content Include="SQL Queries\Create-List-Table.sql" />
    <Content Include="SQL Queries\Create-Templates-Table.sql" />
    <Content Include="SQL Queries\Database Query.sql" />
    <Content Include="SQL Queries\Create-GAMDelegates-Table.sql" />
    <Content Include="SQL Queries\Create-MyPortalPermissions-Table.sql" />
    <Content Include="SQL Queries\Create-UserForms-Table.sql" />
    <None Include="Resources\user %281%29.png" />
    <None Include="Resources\refresh %281%29.png" />
    <Content Include="External Refrences\Interop.ActiveDs.dll" />
    <Content Include="Local Settings\Settings.xml" />
    <Content Include="MyPortal.ico" />
  </ItemGroup>
  <ItemGroup>
    <Analyzer Include="..\packages\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers.0.3.310801\analyzers\dotnet\vb\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers.Common.dll" />
    <Analyzer Include="..\packages\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers.0.3.310801\analyzers\dotnet\vb\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers.dll" />
    <Analyzer Include="..\packages\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers.0.3.310801\analyzers\dotnet\vb\Microsoft.DotNet.UpgradeAssistant.Extensions.Default.CodeFixes.dll" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
    <PackageReference Include="System.DirectoryServices.Protocols" Version="6.0.1" />
    <PackageReference Include="UI.for.WinForms.AllControls.Net60">
      <Version>2022.2.622.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="Custom Controls\CommentPanel.Designer.vb" />
    <Compile Remove="Custom Controls\CommentPanel.vb" />
    <Compile Remove="Custom Controls\ListViewCollapsible.vb" />
    <EmbeddedResource Remove="Custom Controls\CommentPanel.resx" />
  </ItemGroup>
  <ProjectExtensions>
    <VisualStudio>
      <UserProperties ShouldAddDPIScalingManifest="True" />
    </VisualStudio>
  </ProjectExtensions>
  <ItemGroup>
    <None Remove="SQL Queries\Create-Templates-Table.sql" />
    <None Remove="User Forms\ldwise2e.exy~" />
  </ItemGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="DevComponents.DotNetBar2">
      <HintPath>C:\Program Files (x86)\DotNetBar for Windows Forms\DevComponents.DotNetBar2.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="My Project\Resources.resx">
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <Generator>PublicVbMyResourcesResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

Here is the.vbproj of the test app I created to see if it will work on the new pc:这是我创建的测试应用程序的 .vbproj,看看它是否可以在新电脑上运行:

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows</TargetFramework>
    <StartupObject>Sub Main</StartupObject>
    <UseWindowsForms>true</UseWindowsForms>
    <MyType>WindowsForms</MyType>
  </PropertyGroup>

  <ItemGroup>
    <Import Include="System.Data" />
    <Import Include="System.Drawing" />
    <Import Include="System.Windows.Forms" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="My Project\Application.Designer.vb">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Application.myapp</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <None Update="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
  </ItemGroup>

</Project>

Here is the screenshot of my Nuget packages.这是我的 Nuget 包的截图。

在此处输入图像描述

在此处输入图像描述

try this尝试这个

<dependentAssembly>
<assemblyIdentity name="YourDllFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-YourDllFileVersion" newVersion="YourDllFileVersion" />
  • set DeleteExistingFiles = true update all nugget packages and rebuild. set DeleteExistingFiles = true 更新所有 nugget 包并重建。

我可以通过进入我的 license.licx 文件并从文件中删除所有内容来解决这个问题。

Looks like you have the same problem that is reported here .看起来您遇到了与此处报告的问题相同的问题。

You can try the workaround from here: issuecomment-1034371295 :您可以从这里尝试解决方法: issuecomment-1034371295

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM