Also das Ganze sieht bei mir jetzt so aus:
Public Class Form1
Sub New()
Try
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
Catch ex As Exception
Stop
End Try
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf
' hinzu.
End Sub
End Class Normalerweise müsste der Programmablauf jetzt bei "Stop" anhalten, und ich kann mir das ex-Objekt zu Gemüte führen. Nur leider wird die Ausnahme immernoch als unbehandelt angezeigt und es wird nicht angezeigt, an welcher Stelle der Fehler auftrat. Im Stacktrace steht das Folgende:
bei System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal()
bei System.Drawing.Printing.PrinterSettings.GetHdevmode(PageSettings _
pageSettings)
bei System.Drawing.Printing.PrintController.OnStartPrint(PrintDocument _
document, PrintEventArgs e)
bei System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint( _
PrintDocument document, PrintEventArgs e)
bei System.Drawing.Printing.PrintController.Print(PrintDocument document)
bei System.Drawing.Printing.PrintDocument.Print()
bei System.Windows.Forms.PrintPreviewControl.ComputePreview()
bei System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry _
tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
bei System.Threading.ExecutionContext.runTryCode(Object userData)
bei _
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCl_
eanup(TryCode code, CleanupCode backoutCode, Object userData)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext _
executionContext, ContextCallback callback, Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, _
ContextCallback callback, Object state)
bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry _
tme)
bei System.Windows.Forms.Control.InvokeMarshaledCallbacks()
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.PrintPreviewControl.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 _
msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei _
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.Uns_
afeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 _
dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 _
reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 _
reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(ApplicationContext context)
bei _
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRu_
n()
bei _
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoAppl_
icationModel()
bei _
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run( _
String[] commandLine)
bei WindowsApplication1.My.MyApplication.Main(String[] Args) in _
17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence _
assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, _
ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart() Ich frage mich da natürlich, wieso man denn schon bei einem so einfachen Projekt, in das man noch nicht eine einzige Zeile Code geschrieben hat, solche Probleme bekommt, nur weil kein Drucker installiert ist. Wie soll das erst bei komplexen Programmen werden... |