我有一个如下所示的代码
public static Type ToType(Type sType)
{
Assembly assembly = Assembly.Load(SerializableType.AssemblyName);
type = assembly.GetType(sType.Name);
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
在UI中,如果我为基类设置值没有问题,因为它们的程序集创建正常方式,但如果为用户定义的类设置值,则它们的程序集创建不同的方式,如下所示
在我的项目中,我有一个名为'BaseSystem'的基类,并且派生类'RoundedTree'.下面显示的代码'type'对于派生类'RoundedTree'变为null,对于baseclass'BaseSystem',它给出'{ Name = "BaseSystem" FullName = "Root.SystemModel.BaseSystem"}'.我拥有的DLL是Root.SystemModel.dll,它的版本我可以在反射中看到3.6.7.8什么将成为'类型'背后的原因,因为它来自于类
public static Type ToType(UserType usedType)
{
Type type = null;
if (usedTypeType != null
&& usedTypeType.Name != string.Empty)
{
type = Type.GetType(usedType.Name);
Run Code Online (Sandbox Code Playgroud)