TypeInitializationException: “MyButton”的类型初始值设定项引发异常。 --TypeName: MyButton StackTrace: 在 DynamicClass.cc.<初始化>d__fd.MoveNext() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 DynamicClass.a.<OnWindowCreated>d__2.MoveNext() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) ArgumentException: FrameworkElementFactory 已是父级。 --Message: FrameworkElementFactory 已是父级。 StackTrace: 在 System.Windows.FrameworkElementFactory.AppendChild(FrameworkElementFactory child) 在 DynamicClass.MyButton.创建按钮模板() 在 DynamicClass.MyButton..cctor()