Assembly.GetType由于某种原因失败了?

时间:2013-12-24 15:44:15

标签: c#

我的解决方案(称为“Serenity”)中有一个名为“ClassA”的类,但我似乎无法从我提供的位置获取该类型。

Type implementedType = Assembly.GetExecutingAssembly().GetType("Serenity.Maple.Game.Life.Implementation" + lifeDatum.lifeid.ToString());

这就是解决方案的样子:http://puu.sh/5XfI9.png

然而,它失败了。这些类上的命名空间如下:

namespace Serenity.Maple.Game.Life.Implementation

为什么会失败?谢谢。失败我的意思是找不到它..

1 个答案:

答案 0 :(得分:2)

确保命名空间名称和类型名称之间有.。试试这个:

Type implementedType = Assembly
    .GetExecutingAssembly()
    .GetType("Serenity.Maple.Game.Life.Implementation." + lifeDatum.lifeid.ToString());
//                                             added ^
相关问题