vb.net - Using Visual Studio WPF application and 16-bit command.com -


i error when calling program written in vs2013 vb.net older 16 bit msbasic program works if change wpf based library gdi+ based library.

first background:

the pdfsharp library http://www.pdfsharp.net can use gdi or wpf

from pdf sharp web site

pdfsharp .net library processing pdf file. create pdf pages using drawing routines known gdi+. can done gdi+ work pdfsharp. basic text layout supported pdfsharp, , page breaks not created automatically. same drawing routines can used screen, pdf, or meta files.

the libraries provided pdfsharp use drawing routines gdi+ or wpf.

the problem:

the program creating written in vs2013 vb.net. calling program (.exe file) old microsoft basic program uses command.com launch programs. error when using command /c pdftest.exe launch program. not error when using cmd.exe using command cmd /c pdftest.exe. not error when using same program using gdi+ library version of pdfsharp.dll.

i know command.com 16 bit program , cmd.exe 32 bit. understanding command.com uses cmd.exe call programs, different? gdi+ version of pdfsharp.dll fine. test code form 1 button calls following code:

    ' create new pdf document     dim document pdfdocument = new pdfdocument     document.info.title = "created pdfsharp"      ' create empty page     dim page pdfpage = document.addpage      ' xgraphics object drawing     dim gfx xgraphics = xgraphics.frompdfpage(page)      ' draw crossing lines     dim pen xpen = new xpen(xcolor.fromargb(255, 0, 0))      ' create font     dim font xfont = new xfont("verdana", 20, xfontstyle.bold)      ' draw text     gfx.drawstring("hello, world!", font, xbrushes.black, _     new xrect(0, 0, page.width.point, page.height.point), xstringformats.center)      ' save document...     dim filename string = "helloworld.pdf"     document.save(filename) 

here error

see end of message details on invoking  just-in-time (jit) debugging instead of dialog box.  ************** exception text ************** system.typeinitializationexception: type initializer 'system.windows.media.fontfamily' threw exception. ---> system.typeinitializationexception: type initializer 'ms.internal.fontcache.util' threw exception. ---> system.uriformatexception: invalid uri: format of uri not determined. @ system.uri.createthis(string uri, boolean dontescape, urikind urikind) @ system.uri..ctor(string uristring, urikind urikind) @ ms.internal.fontcache.util..cctor() --- end of inner exception stack trace --- @ system.windows.media.fontfamily..cctor() --- end of inner exception stack trace --- @ system.windows.media.typeface..ctor(fontfamily fontfamily, fontstyle style, fontweight weight, fontstretch stretch) @ pdfsharp.drawing.fonthelper.createtypeface(fontfamily family, xfontstyle style) @ pdfsharp.drawing.xfont.initialize() @ pdfsharp.drawing.xfont..ctor(string familyname, double emsize, xfontstyle style) @ pdfsharptestwin.pdfsharptestwin.cmdbasictest_click(object sender, eventargs e) @ system.windows.forms.control.onclick(eventargs e) @ system.windows.forms.button.onclick(eventargs e) @ system.windows.forms.button.onmouseup(mouseeventargs mevent) @ system.windows.forms.control.wmmouseup(message& m, mousebuttons button, int32 clicks) @ system.windows.forms.control.wndproc(message& m) @ system.windows.forms.buttonbase.wndproc(message& m) @ system.windows.forms.button.wndproc(message& m) @ system.windows.forms.control.controlnativewindow.onmessage(message& m) @ system.windows.forms.control.controlnativewindow.wndproc(message& m) @ system.windows.forms.nativewindow.callback(intptr hwnd, int32 msg, intptr wparam, intptr lparam) 

i trying post on pdfsharp forum too. having trouble registration system. never verification emails. though try here too.

i have found problem , solution. problem not pdfsharp. .net wpf application in general. wpf application created visual studio requires environment variable windir set windows directory. when using 16-bit command.com not have windir environment variable. adding environment variable before running .net wpf application allows application run.

researching on internet, many sites consider bug. agree. visual studio applications need either more gracefully exit error message or better yet use systemroot instead. appears .net applications based on winforms not have requirement.

to make change permanent on windows workstation, edit file autoexec.nt in c:\windows\system32 or %systemroot%\system32 adding line

set windir=%systemroot% 

https://social.msdn.microsoft.com/forums/vstudio/en-us/b54f4d59-e62f-467d-9a51-daff5e7947a2/what-is-best-to-do-if-windir-environment-variable-does-not-exist?forum=wpf

http://nerdynotes.blogspot.com/2010/05/wpf-program-crashes-when-started-from.html


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -