TypeBuilder中缺少CreateType。如何移植呢? [英] CreateType missing from TypeBuilder. How to port this?

查看:200
本文介绍了TypeBuilder中缺少CreateType。如何移植呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将应用程序从.net 4.5移植到客户端的.net core。我注意到CreateType不再是TypeBuilder的一部分。我查过多个新的反射库,但没有运气。有人知道如何移植吗?

Trying to port an application from .net 4.5 to .net core for a client. I'm noticing that CreateType is no longer part of TypeBuilder. I've searched through multiple of the new reflection libs with no luck. Does anyone know how to port this?

有问题的代码:

typeBuilder.CreateType()


推荐答案

我找到了答案,但在与我预期不同的存储库中。删除了CreateType,现在应按以下方式使用CreateTypeInfo:

I found the answer, but in a different repository than I expected. CreateType was dropped, and CreateTypeInfo should be used now per this:

https://github.com/dotnet/coreclr/issues/2222



'TypeBuilder'不包含'CreateType'的定义,并且找不到
扩展方法'CreateType'接受类型为
'TypeBuilder'的第一个参数(是否缺少using指令或
程序集引用?)

'TypeBuilder' does not contain a definition for 'CreateType' and no extension method 'CreateType' accepting a first argument of type 'TypeBuilder' could be found (are you missing a using directive or an assembly reference?)

请改用typeBuilder.CreateTypeInfo()。

Use typeBuilder.CreateTypeInfo() instead.

希望这可以节省其他人的时间。

Hope this saves someone else time.

这篇关于TypeBuilder中缺少CreateType。如何移植呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆