.NET 3.5 응용 프로그램에서 새 UI 스레드를 만들려면 다음 코드를 사용하십시오.WPF Dispatcher.Run이 Win 7에서 null 예외를 throw합니다. 64
private void OnCreateNewWindow(object sender, RoutedEventArgs e)
{
var rect = this.RestoreBounds;
double l = rect.Left;
double wth = rect.Width;
double t = rect.Top;
double ht = rect.Height;
var progressThread = new Thread(() =>
{
progressWindow = new ProgressWindow(Visibility.Collapsed) { Height = 50, Width = 50 };
progressWindow.WindowStartupLocation = WindowStartupLocation.Manual;
progressWindow.Left = l + (wth - progressWindow.Width)/2;
progressWindow.Top = t - 35 + (ht - progressWindow.Height)/2;
progressWindow.Show();
progressWindow.Activate();
Dispatcher.Run();
});
progressThread.SetApartmentState(ApartmentState.STA);
progressThread.Start();
}
충돌은 여기에 설명된다 : 이것은 윈도우 32 비트 버전에서 완벽하게 작동
. 64 비트 Windows 7에서 PC를 재부팅 할 때이 프로그램을 처음 실행할 때 Visual Studio 나 Visual Studio 외부에서 응용 프로그램 충돌을 통해 실행되는 경우 null 예외가 발생합니다.
예외 정보가 건조 :
[Managed to Native Transition]
WindowsBase.dll!MS.Win32.HwndWrapper.DestroyWindow(object args) + 0xfc bytes
WindowsBase.dll!MS.Win32.HwndWrapper.Dispose(bool disposing, bool isHwndBeingDestroyed) + 0xce bytes
WindowsBase.dll!MS.Win32.HwndWrapper.Dispose() + 0x15 bytes
PresentationCore.dll!System.Windows.Media.MediaContextNotificationWindow.DisposeNotificationWindow() + 0x22 bytes
PresentationCore.dll!System.Windows.Media.MediaContext.Dispose() + 0xba bytes
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(object state) + 0x47 bytes
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x178 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x62 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.ShutdownImpl() + 0x87 bytes
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) + 0x121 bytes
> EMS.Controls.Dictionary.dll!EMS.Controls.Dictionary.Views.AuthenticateWindow.OnCreateNewWindow.AnonymousMethod() Line 56 + 0x5 bytes C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x9b bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x4d bytes
내가 다시 프로그램을 계속 실행하면, 나는 것을 나타내는, 프로그램 호환성 Assitant에서 메시지를받을 :
System.NullReferenceException was unhandled
스택 추적이 아래에 주어진다 일부 호환성 설정이 적용되었습니다. 다음에 프로그램을 실행하면 더 이상이 예외가 발생하지 않습니다. 누구든지이 경험이 있습니까?
스택 추적을 게시 할 수 있습니까? –
스택 추적이있는 수정 된 소식입니다. 그것은 매우 건조하다. 감사. –
[외부 코드]를 마우스 오른쪽 버튼으로 클릭하고 "외부 코드 표시"를 선택하십시오 –