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