internal static string GetFilenameWinForms(MenuSystem console) { #if NO_APP_WINFORMS throw new NotSupportedException("NO_APP_WINFORMS"); #else string fileSource; try { EventHandler action = delegate { var d = new System.Windows.Forms.OpenFileDialog(); if (d.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } fileSource = d.FileName; }; fileSource = null; console.UiInvoke(action); if (fileSource == null) { return(null); } } catch (NotSupportedException) { #if !NETCF Trace.Fail("Why NotSupportedException on OpenFileDialog?!?"); #endif // NETCF on Standard fileSource = console.ReadLine("Which file"); } return(fileSource); #endif }
private void InvokeWC(object unusedParameter) { #if false && !NETCF Invoke(); #else try { Invoke(); } catch (Exception ex) { ex = GetOriginalException(ex); // string prefix = null; var soex = ex as System.Net.Sockets.SocketException; if (soex != null) { prefix = "(" + soex.ErrorCode.ToString(CultureInfo.InvariantCulture) #if !NETCF + " " + soex.SocketErrorCode.ToString() #endif + ") "; } console.WriteLine("Swallowed Exception: " + prefix + ex); console.ReadLine("Continuing after: " + prefix + ToStringFirstLine(ex)); } #endif }