可收集ALC问题[A non-collectible assembly may not reference a collectible assembly.]

ITask程序集在共享类库中定义,初衷是任务调度程序,创建新的可卸载ALC以供每一个任务运行,此时会出现两个问题:
- 任务调度程序加载了任务程序后,任务程序中的ITask类型和任务调度程序中的ITask类型不是同一个类型。
- 若在可回收的ALC中使用Xml序列化,会报异常:A non-collectible assembly may not reference a collectible assembly.
问题2的堆栈跟踪
at System.Reflection.Emit.ModuleBuilder.GetTypeRef(QCallModule module, String strFullName, QCallModule refedModule, String strRefedModuleFileName, Int32 tkResolution)
at System.Reflection.Emit.ModuleBuilder.GetTypeRefNested(Type type, Module refedModule, String strRefedModuleFileName)
at System.Reflection.Emit.ModuleBuilder.GetTypeTokenWorkerNoLock(Type type, Boolean getGenericDefinition)
at System.Reflection.Emit.ModuleBuilder.GetTypeTokenInternal(Type type, Boolean getGenericDefinition)
at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, Type cls)
at System.Xml.Serialization.CodeGenerator.Castclass(Type target)
at System.Xml.Serialization.CodeGenerator.InternalConvert(Type source, Type target, Boolean isAddress)
at System.Xml.Serialization.SourceInfo.InternalLoad(Type elementType, Boolean asAddress)
at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElement(SourceInfo source, ElementAccessor element, String arrayName, Boolean writeAccessor)
at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElements(SourceInfo source, String enumSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, String arrayName, Boolean writeAccessors, Boolean isNullable)
at System.Xml.Serialization.XmlSerializationWriterILGen.WriteMember(SourceInfo source, String choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc memberTypeDesc, Boolean writeAccessors)
at System.Xml.Serialization.XmlSerializationWriterILGen.GenerateTypeElement(XmlTypeMapping xmlTypeMapping)
at System.Xml.Serialization.XmlSerializationWriterILGen.GenerateElement(XmlMapping xmlMapping)
at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
问题1:
可收集ACL中也加载了一份ITask所在的程序集,而宿主程序中也加载了一份,因此.net core认为不是同一个类型。
在可收集ACL的Load方法中,跳过加载ITask所在程序集即可,这样当可收集ACL需要使用ITask程序集时,会从宿主程序中查找,即Load方法返回null时对应的程序集都会从宿主程序中查找。
问题2:
.NET5 Preview1中会解决Xml序列化的问题
github上的issues,其中就有提到这两个问题
https://github.com/dotnet/runtime/issues/1388
可收集ALC问题[A non-collectible assembly may not reference a collectible assembly.]的更多相关文章
- 【Assembly】NO.70.EBook.7.Assembly.1.001-【汇编语言 第3版 张爽】- 基础知识
1.0.0 Summary Tittle:[Assembly]NO.70.EBook.7.Assembly.1.001-[汇编语言 第3版 张爽]- 基础知识 Style:Assembly Serie ...
- Change Assembly Version in a compiled .NET assembly
Change Assembly Version in a compiled .NET assembly You can use ILMerge: ILMerge.exe Foo.dll /ver:1. ...
- ASP.NET corrupt assembly “Could not load file or assembly App_Web_*
以下是从overFlow 复制过来的问题 I've read through many of the other questions posted on the same issue, but I s ...
- .NET 程序集Assembly使用
概述 一直以来,我们都在用C#编写程序,编写程序的时候,我们用到继承.多态.接口以及泛型,我们也都明白子类可以继承抽象类,并能够重写父类的抽象方法,可是大家是否想过,如下几个问题: 1.凡树必有根和叶 ...
- 加载dll过程中assembly失败
错误现象: 进行插件读取时出现错误:“尝试从一个网络位置加载程序集,在早期版本的 .NET Framework 中,这会导致对该程序集进行沙盒处理.此发行版的 .NET Framework 默认情况下 ...
- [转]C#反射-Assembly.Load、LoadFrom与LoadFile进阶
关于.NET中的反射,常用的有三个方法: Assembly.Load()Assembly.LoadFrom()Assembly.LoadFile() 下面说说这三个方法的区别和一些细节问题 1. As ...
- No assembly found containing an OwinStartupAttribute
自从在ASP.NET MVC中使用NuGet添加SignalR类库之后,再次运行程序时,它出现了一个异常: Server Error in '/' Application. The following ...
- 慎用Assembly.LoadFile()和Assembly.LoadFrom()
经测这俩方法会锁住文件,导致程序运行期间无法对load过的程序集文件进行更名/删除/覆盖等等操作,考虑用Assembly.Load()文件字节组替代: Assembly.Load(File.ReadA ...
- sbt的assembly插件使用(打包所有依赖)
1.sbt是什么 对于sbt 我也是小白, 为了搞spark看了一下scala,学习scala时指定的构建工具就是sbt(因为sbt也是用scala开发的嘛),起初在我眼里就是一个maven(虽然ma ...
- How to upgrade workflow assembly in MOSS 2007
This problem generally start when you are having an existing custom workflow and there are instances ...
随机推荐
- Vue 禁止按钮多次点击 重复提交数据(指令实现)
全局定义,方便调用 新建plugins.js export default { install (Vue) { // 防重复点击(指令实现) Vue.directive('preventReClick ...
- StatefulWidget 组件的参数时(widget.xxx)报 Invalid Constant Value
一个 Flutter 组件(Widget)在很多情况下都需要接收一些参数.Flutter 插件通常提示使用 const 关键字包裹某 Widget(很多人接受建议且执行),导致通过 widget.xx ...
- Mars3D与第三方集成
1. 引言 Mars3D是基于Cesium的Web端的三维GIS库,对Cesium做了进一步封装和扩展 Mars3D官网:Mars3D三维可视化平台 | 火星科技 Mars3D开发手册:开发教程 - ...
- Java第五讲异常处理总结
1. 在运行上述代码时javac产生idiv字节码指令,在运行下面的程序时javac产生ddiv字节指令,导致了两段代码运行结果不同. 2. 3.finally语句块一定会执行吗? /** * 自定义 ...
- B树,B-树,B+树和B*树
B树和B-树(平衡多路查找树)规则:1.排序方法:所有结点关键字按递增次序,并遵循左小右大的原则.2.子结点数:非叶子结点的子结点数>1且<=M且M>=2,空树除外(M阶代表一个树的 ...
- Windows 远程桌面连接ip查询
导航到:应用程序和服务日志 > Microsoft > Windows > TerminalServices- RemoteConnectionManager,右键单击"O ...
- QueryObject
1 package com.ygm.aa.page.qo; 2 3 import lombok.Getter; 4 import lombok.NoArgsConstructor; 5 import ...
- leetcode刷题(三)
1.图论 找到小镇的法官 在一个小镇里,按从 1 到 N 标记了 N 个人.传言称,这些人中有一个是小镇上的秘密法官. 如果小镇的法官真的存在,那么: 小镇的法官不相信任何人.每个人(除了小镇法官外) ...
- .NetCore2.0引用DLL报System.InvalidOperationException: Can not find compilation library location for package 'XXX'
.NET CORE 2.0 MVC项目引用类库出现:System.InvalidOperationException: Can not find compilation library locatio ...
- ubuntu18 电脑重启后登录后无法进入桌面
ubuntu18 电脑重启后登录后无法进入桌面 应该是ubuntu桌面管理器gdm3和nvidia驱动冲突导致的 解决办法: 首先卸载已有的nvidia驱动 注意:在下载完驱动后,此时电脑没有驱动文件 ...