我想在检索时显示一条带有用户友好消息的进度对话框数据。我正在使用Visual Studio2010。我尝试使用此代码/// <summary> /// Shows a progress message to the user. /// </summary> /// <param name="header">The header text for the dialog.</param> /// <param name="message">The message to be displayed in the dialog.</param> void ShowProgressMessage(string header, string message) { _isMessageDialogVisible = true; _controller = _metroWindow.ShowProgressAsync(header, message); } /// <summary> /// Closes a message dialog that is visible. /// </summary> void CloseProgressMessage() { if (_isMessageDialogVisible) { _isMessageDialogVisible = false; if (null != _controller) { var controller = _controller.Result; controller.CloseAsync(); } } }但它给出一个错误,指出:22 09 2015 [9] DEBUG - OPGSpiral Error App.AppDispatcherUnhandledException --- System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme()   在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize()   在MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor中(MetroWindow owningWindow,MetroDialogSettings设置)   在MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow,MetroDialogSettings设置)   在MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow)   在MahApps.Metro.Controls.Dialogs.DialogManager。 c__DisplayClass43.b__3b()   ---内部异常堆栈跟踪的结尾---   在System.RuntimeMethodHandle.InvokeMethod处(对象目标,对象[]参数,签名sig,布尔构造函数)   在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object []参数,Object []参数)   在System.Delegate.DynamicInvokeImpl(Object [] args)   在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象args,Int32 numArgs)   在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象args,Int32 numArgs,委托catchHandler)2015年9月22日[9]调试-OPGSpiral错误App.AppDispatcherUnhandledException --- System.Reflection.TargetInvocationException:调用的目标引发了异常。 ---> System.NullReferenceException:对象引用未设置为对象的实例。   在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme()   在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize()   在MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor中(MetroWindow owningWindow,MetroDialogSettings设置)   在MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow,MetroDialogSettings设置)   在MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow)   在MahApps.Metro.Controls.Dialogs.DialogManager。 c__DisplayClass43.b__3b()   ---内部异常堆栈跟踪的结尾---   在System.RuntimeMethodHandle.InvokeMethod处(对象目标,对象[]参数,签名sig,布尔构造函数)   在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object []参数,Object []参数)   在System.Delegate.DynamicInvokeImpl(Object [] args)   在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象args,Int32 numArgs)   在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象args,Int32 numArgs,委托catchHandler) (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 这应该在1.2.2中修复,可以通过NuGet获得。 (adsbygoogle = window.adsbygoogle || []).push({});
10-05 23:10