我從一個較舊的16位MSBasic程序調用在VS2013 vb.net中編寫的程序時出現錯誤,但是如果我從基於WPF的庫更改爲基於GDI +圖書館。使用Visual Studio WPF應用程序和16位command.com
首先是一些背景:
從http://www.pdfsharp.net的PDFSharp庫可以使用GDI或WPF
從PDF SHARP WEB SITE
PDFsharp是用於處理PDF文件.NET庫。您可以使用GDI +中的繪圖程序創建PDF 頁面。幾乎所有可以用GDI +完成的任何事情都可以使用PDFsharp。 PDFsharp僅支持基本的文本佈局 ,並且分頁不會自動創建 。相同的繪圖例程可用於屏幕,PDF, 或元文件。
PDFSharp提供的庫使用來自GDI +或WPF的繪圖例程。
問題:
我創建的程序被寫在VS2013 VB.NET。我從舊的Microsoft Basic程序中調用該程序(.EXE文件),該程序使用command.com
來啓動程序。使用command /c pdftest.exe
啓動程序時出現錯誤。但是,當使用命令cmd /c pdftest.exe
使用cmd.exe
時,我不會收到錯誤。另外,當使用相同的程序但使用PDFSharp.dll
的GDI +庫版本時,我不會收到錯誤。
我知道command.com
是一個16位程序,而cmd.exe
是32位。我的理解是,command.com
使用cmd.exe
來調用任何程序,所以有什麼不同? GDI +版本PDFSharp.dll
也沒問題。我的測試代碼只是一個按鈕調用下面的代碼形式:
' Create a new PDF document
Dim document As PdfDocument = New PdfDocument
document.Info.Title = "Created with PDFsharp"
' Create an empty page
Dim page As PdfPage = document.AddPage
' Get an XGraphics object for drawing
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
' Draw crossing lines
Dim pen As XPen = New XPen(XColor.FromArgb(255, 0, 0))
' Create a font
Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)
' Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black, _
New XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center)
' Save the document...
Dim filename As String = "HelloWorld.pdf"
document.Save(filename)
這裏是
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.TypeInitializationException: The type initializer for 'System.Windows.Media.FontFamily' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MS.Internal.FontCache.Util' threw an exception. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at MS.Internal.FontCache.Util..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.FontFamily..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.Typeface..ctor(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
at PdfSharp.Drawing.FontHelper.CreateTypeface(FontFamily family, XFontStyle style)
at PdfSharp.Drawing.XFont.Initialize()
at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyle style)
at PDFSharpTestWin.PDFSharpTestWin.cmdBasicTest_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我想張貼在論壇PDFSharp過錯誤。但是他們的註冊系統有問題。我從來沒有得到他們的驗證電子郵件。所以儘管我也會在這裏嘗試。