.NET Framework 4.8迁移至.NET 6后出现FileNotFoundException问题
.NET Framework 4.8迁移至.NET 6后CodeBase.Viewer项目加载CodeBase.Core失败问题
运行迁移后的CodeBase.Viewer项目时出现以下运行时错误:
Exception: System.TypeInitializationException: 'The type initializer for 'Common.Utilities.ApplicationProperties' threw an exception.' Inner exception: FileNotFoundException: Could not load file or assembly 'CodeBase.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a395f90ece4b52e0'. The system cannot find the file specified.
已进行的排查操作:
- CodeBase.Core.dll已存在于构建文件夹,版本与文件属性一致,公钥令牌通过
[system.reflection.assembly]::loadfile("pathToCore")).FullName验证匹配 - 使用Assembly Binding Log Viewer未捕获到该加载异常
- 尝试移除并重新添加CodeBase.Core项目引用,问题未解决
- 将CodeBase.Core项目引用的“复制到本地文件夹”设为true,问题未解决
- 同解决方案中的CodeBase.csproj运行相同代码无异常
正常项目文件(CodeBase.csproj)
<Project Sdk="Microsoft.NET.Sdk"> <Import Project="..\CodeBase.props" /> <PropertyGroup> <TargetFramework>net6.0-windows</TargetFramework> <OutputType>WinExe</OutputType> <IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath> <OutputPath>$(BaseOutputPath)CodeBase\$(Platform)\$(Configuration)\CodeBase\</OutputPath> <CodeAnalysisRuleSet>..\CodeBase.ruleset</CodeAnalysisRuleSet> <CodeAnalysisLogFile>$(BuiltPath)CodeBase\$(Platform)\$(Configuration)\CodeAnalysis\$(MSBuildProjectName).CodeAnalysisLog.xml</CodeAnalysisLogFile> <GenerateAssemblyInfo>True</GenerateAssemblyInfo> <Platforms>x64</Platforms> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <UseWindowsForms>true</UseWindowsForms> <UseWPF>true</UseWPF> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets> <GenerateProgramFile>false</GenerateProgramFile> <EnableDefaultApplicationDefinition>false</EnableDefaultApplicationDefinition> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <DocumentationFile>$(BuiltPath)CodeBase\x64\Release\CodeBase\CodeBase.xml</DocumentationFile> </PropertyGroup> <PropertyGroup> <ApplicationIcon>..\CodeBase.Common\Resources\Icons\CodeBase.ico</ApplicationIcon> </PropertyGroup> <PropertyGroup> <SignAssembly>true</SignAssembly> </PropertyGroup> <PropertyGroup> <AssemblyOriginatorKeyFile>..\CodeBase.snk</AssemblyOriginatorKeyFile> </PropertyGroup> <PropertyGroup> <ApplicationManifest>app.manifest</ApplicationManifest> </PropertyGroup> <ItemGroup> <None Include="..\CodeBase.ruleset"> <Link>CodeBase.ruleset</Link> </None> <None Include="..\CodeBase.snk"> <Link>CodeBase.snk</Link> </None> <AppDesigner Include="Properties\" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\CodeBase.Activation\CodeBase.Activation.csproj" /> <ProjectReference Include="..\CodeBase.Common\CodeBase.Common.csproj" /> <ProjectReference Include="..\CodeBase.Controls\CodeBase.Controls.csproj" /> <ProjectReference Include="..\CodeBase.Converter\CodeBase.Converter.csproj" /> <ProjectReference Include="..\CodeBase.Core\CodeBase.Core.csproj" /> <ProjectReference Include="..\CodeBase.Graphics\CodeBase.Graphics.csproj" /> <ProjectReference Include="..\CodeBase.Home\CodeBase.Home.csproj" /> <ProjectReference Include="..\CodeBase.IO.Data\CodeBase.IO.Data.csproj" /> <ProjectReference Include="..\CodeBase.IO.Options\CodeBase.IO.Options.csproj" /> <ProjectReference Include="..\CodeBase.IO\CodeBase.IO.csproj" /> <ProjectReference Include="..\CodeBase.Library\CodeBase.Library.csproj" /> <ProjectReference Include="..\CodeBase.License\CodeBase.License.csproj" /> <ProjectReference Include="..\CodeBase.Public\CodeBase.Public.csproj" /> <ProjectReference Include="..\CodeBase.SDK\CodeBase.SDK.csproj" /> <ProjectReference Include="..\CodeBase.UI.Graphics\CodeBase.UI.Graphics.csproj" /> <ProjectReference Include="..\CodeBase.UI.Options\CodeBase.UI.Options.csproj" /> <ProjectReference Include="..\CodeBase.Viewer\CodeBase.Viewer.csproj" /> <ProjectReference Include="..\CodeBase.WindowsShellExtensions\CodeBase.WindowsShellExtensions.csproj" /> <ProjectReference Include="..\CodeBase.Workspace\CodeBase.Workspace.csproj" /> </ItemGroup> <ItemGroup> <Resource Include="Resources\Images\Logo.png" /> </ItemGroup> <ItemGroup> <Resource Include="Resources\Images\SplashScreen.png" /> </ItemGroup> <PropertyGroup> <PostBuildEvent>echo *** Post-build $(MSBuildProjectName) *** powershell.exe "& '$(SolutionDir)..\Powershell\Deploy.ps1'" $(Platform)\$(Configuration) echo *** End of post-build $(MSBuildProjectName) ***</PostBuildEvent> </PropertyGroup> </Project>
异常项目文件(CodeBase.Viewer.csproj)
<Project Sdk="Microsoft.NET.Sdk"> <Import Project="..\CodeBase.props" /> <PropertyGroup> <TargetFramework>net6.0-windows</TargetFramework> <OutputType>WinExe</OutputType> <IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath> <OutputPath>$(BaseOutputPath)CodeBase\$(Platform)\$(Configuration)\CodeBase\</OutputPath> <CodeAnalysisRuleSet>..\CodeBase.ruleset</CodeAnalysisRuleSet> <CodeAnalysisLogFile>$(BuiltPath)CodeBase\$(Platform)\$(Configuration)\CodeAnalysis\$(MSBuildProjectName).CodeAnalysisLog.xml</CodeAnalysisLogFile> <GenerateAssemblyInfo>True</GenerateAssemblyInfo> <Platforms>x64</Platforms> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <UseWindowsForms>true</UseWindowsForms> <UseWPF>true</UseWPF> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets> <GenerateProgramFile>false</GenerateProgramFile> <EnableDefaultApplicationDefinition>false</EnableDefaultApplicationDefinition> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <DocumentationFile>$(BuiltPath)CodeBase\$(Platform)\$(Configuration)\CodeBase\CodeBase.Viewer.xml</DocumentationFile> </PropertyGroup> <PropertyGroup> <ApplicationIcon>..\CodeBase.Common\Resources\Icons\CodeBase.ico</ApplicationIcon> </PropertyGroup> <PropertyGroup> <SignAssembly>true</SignAssembly> </PropertyGroup> <PropertyGroup> <AssemblyOriginatorKeyFile>..\CodeBase.snk</AssemblyOriginatorKeyFile> </PropertyGroup> <PropertyGroup> <ApplicationManifest>app.manifest</ApplicationManifest> </PropertyGroup> <ItemGroup> <None Include="..\CodeBase.ruleset"> <Link>CodeBase.ruleset</Link> </None> <None Include="..\CodeBase.snk"> <Link>CodeBase.snk</Link> </None> <AppDesigner Include="Properties\" /> <EmbeddedResource Include="Resources\Scripting\Python.Classic.xshd" /> <EmbeddedResource Include="Resources\Scripting\Python.ModernDark.xshd" /> <EmbeddedResource Include="Resources\Scripting\Python.ModernLight.xshd" /> <EmbeddedResource Include="Resources\Scripting\Python.Visualize.xshd" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\CodeBase.Common\CodeBase.Common.csproj" /> <ProjectReference Include="..\CodeBase.Controls\CodeBase.Controls.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.Core\CodeBase.Core.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.Drawing\CodeBase.Drawing.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.Geometry\CodeBase.Geometry.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.Graphics\CodeBase.Graphics.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.IO.Data\CodeBase.IO.Data.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.IO.Options\CodeBase.IO.Options.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.IO\CodeBase.IO.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.License\CodeBase.License.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.LinearAlgebra\CodeBase.LinearAlgebra.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.Scripting\CodeBase.Scripting.csproj"> </ProjectReference> <ProjectReference Include="..\CodeBase.UI.Graphics\CodeBase.UI.Graphics.csproj"> </ProjectReference> </ItemGroup> <ItemGroup> <Compile Remove="ViewModels\Markups\SelectionBoxViewModel.cs" /> </ItemGroup> </Project>
请问各位有什么解决建议吗?
内容的提问来源于stack exchange,提问作者Yamithrain
相关产品推荐
相关产品推荐

