2011-11-15 147 views
0

我有一個用VS2010編寫的WPF程序,一切正常。創建一個Windows安裝程序項目,並建立好了。很好地運行setup.exe文件。當我來到運行安裝的應用程序沒有任何反應約10秒鐘,然後我得到的程序已停止工作等安裝後WPF程序崩潰

如果我進入事件查看器,我可以看到應用程序已拋出以下錯誤:

Application: BarcodeScanner.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.IOException 
Stack: 
    at MS.Internal.AppModel.ResourcePart.GetStreamCore(System.IO.FileMode, System.IO.FileAccess) 
    at System.IO.Packaging.PackagePart.GetStream(System.IO.FileMode, System.IO.FileAccess) 
    at System.IO.Packaging.PackagePart.GetStream() 
    at System.Windows.Application.LoadComponent(System.Uri, Boolean) 
    at System.Windows.Application.DoStartup() 
    at System.Windows.Application.<.ctor>b__1(System.Object) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
    at System.Windows.Threading.DispatcherOperation.InvokeImpl() 
    at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) 
    at System.Threading.ExecutionContext.runTryCode(System.Object) 
    at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) 
    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Windows.Threading.DispatcherOperation.Invoke() 
    at System.Windows.Threading.Dispatcher.ProcessQueue() 
    at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
    at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) 
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) 
    at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) 
    at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) 
    at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) 
    at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 
    at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 
    at System.Windows.Application.RunDispatcher(System.Object) 
    at System.Windows.Application.RunInternal(System.Windows.Window) 
    at System.Windows.Application.Run(System.Windows.Window) 
    at System.Windows.Application.Run() 
    at BarcodeScanner.App.Main() 

有沒有人知道爲什麼會發生這種情況?

請讓我知道,如果你需要了解任何信息/細節。

回答

1

您是否試圖訪問文件?

at MS.Internal.AppModel.ResourcePart.GetStreamCore(System.IO.FileMode, System.IO.FileAccess)

如果沒有嘗試查看您的應用程序是否可以訪問網絡。它似乎有一個文件的問題。它可以是關於您嘗試讀取的配置讀取文件或流文件。

嘗試把一些嘗試和趕上文件訪問!

+0

有一個配置文件。配置文件與可執行文件位於同一文件夾中。如果問題出在讀配置文件,我會在哪裏將try catch放在程序中? – user589195

+0

如何打開文件?使用流?附上打開文件/流的代碼塊 – sll

+0

唯一的文件訪問是使用標準.net方法的配置文件。我沒有代碼來手動加載文件,我只是使用System.Configuration.ConfigurationManager.AppSettings [「ILPrintExportPath」]; – user589195

0

修正了它。

問題在於文化資源文件不存在。