帮帮我 - 为什么这段代码在 .NET 4.0 下运行时会导致 VerificationException?
public T parseEnum<T>(string value, T defaultValue) {
//Removing the following lines fixes the problem
if (!typeof(T).IsEnum) throw new ArgumentException("T must be an enumerated type");
return defaultValue;
}
我peverify
在 .net 2.0 程序集上运行并收到以下消息:
ImageResizer.Util.Utils::parseEnum[T]][offset 0x0000000A] 调用的'this'参数必须是调用方法的'this'参数。
VerificationException: Operation could destabilize the runtime
在中等信任下运行代码时,这会导致一条消息。
我已经阅读了所有关于堆栈溢出的类似帖子,但没有一篇适用于这段代码。
泛型是否有一些新的东西会导致这段代码在某种程度上无效?