1
任何人都知道为什么这不会编译?问题与从工作流程活动继承有关。错误编译与泛型和工作流活动基类
public class MyActivityBase<T> : System.Workflow.ComponentModel.Activity
{
public T MyProperty { get; set; }
}
编译错误消息
Error 1 Could not create activity of type '...Activities.Common.MyActivityBase`1'. System.ArgumentException: Cannot create an instance of ...Activities.Common.MyActivityBase`1[T] because Type.**ContainsGenericParameters is true**. at System.RuntimeType.CreateInstanceCheckThis() at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Workflow.ComponentModel.Compiler.XomlCompilerHelper.InternalCompileFromDomBatch(String[] files, String[] codeFiles, WorkflowCompilerParameters parameters, WorkflowCompilerResults results, String localAssemblyPath)
谢谢, Ť
Hello Thomas。我想提请你注意一些事情。一旦提供可接受的答案,接受答案是很常见的做法。您可以回到以前的问题并单击所需答案左侧的大型支票图片来接受答案。你接受的答案越多,人们就越有可能想回答你未来的问题。查看FAQ获取更多帮助。 – MPelletier 2011-05-27 20:37:28