首页 > Web开发 > 详细

.net 5 单文件模式发布异常 CodeBase is not supported on assemblies loaded from a single-file bundle

时间:2021-04-29 14:53:52      阅读:60      评论:0      收藏:0      [点我收藏+]

.net 5 单文件模式发布异常 CodeBase is not supported on assemblies loaded from a single-file bundle

异常明细

Unhandled exception. System.NotSupportedException: CodeBase is not supported on assemblies loaded from a single-file bundle.
   at System.Reflection.RuntimeAssembly.get_CodeBase()
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.GetNormalizedCodeBasePath(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.GetDepsJsonPath(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadAssemblyContext(Assembly assembly, IDependencyContextReader reader)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContext.Load(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()

文档地址: https://docs.microsoft.com/en-us/dotnet/core/compatibility/5.0#assembly-related-api-behavior-changes-for-single-file-publishing-format

与程序集文件位置相关的多个API以单文件发布格式被调用时,其行为会发生变化
因为单文件程序集都合并为一个了,所以有一些路径相关的API均无法支持

GitHub Issue

https://github.com/dotnet/runtime/pull/42306
技术分享图片
技术分享图片

技术分享图片
https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/5.0/assembly-api-behavior-changes-for-single-file-publish+

解决方法
Avoid dependencies on the file location of assemblies when publishing as a single file.
作为单个文件发布时,避免依赖程序集的文件位置。

.net 5 单文件模式发布异常 CodeBase is not supported on assemblies loaded from a single-file bundle

原文:https://www.cnblogs.com/WNpursue/p/14717646.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!