我知道這並不理想,但我的約束是我有一個用Clipper編寫的遺留應用程序。如何從command.com啓動WPF應用程序。我得到一個FontCache錯誤
我想從應用程序內部啓動一個新的WinForms/WPF應用程序(以簡化轉換)。這寫在快船遺留應用程序啓動使用:
SwpRunCmd("C:\MyApp\MyBat.bat",0)
批處理文件包含這樣的命令:
C:\PROGRA~1\INTERN~1\iexplore "http://QASVR/MyApp/AppWin/MyCompany.MyApp.AppWin.application#MyCompany.MyApp.AppWin.application"
它發射的WinForms/WPF應用程序,是我們通過的ClickOnce部署。直到我們將WPF引入到應用程序中之前,一切都進行得很順利。我們能夠從傳統應用程序輕鬆啓動。
由於我們引入了WPF,但是,我們有以下行爲。如果我們首先通過Clipper應用程序啓動,那麼啓動應用程序時會遇到異常。錯誤文本是:
The type initializer for 'System.Windows.FrameworkElement' threw an exception.
at System.Windows.FrameworkElement..ctor()
at System.Windows.Controls.Panel..ctor()
at System.Windows.Controls.DockPanel..ctor()
at System.Windows.Forms.Integration.AvalonAdapter..ctor(ElementHost hostControl)
at System.Windows.Forms.Integration.ElementHost..ctor()
at MyCompany.MyApp.AppWin.Main.InitializeComponent()
at MyCompany.MyApp.AppWin.Main..ctor(String[] args)
at MyCompany.MyApp.AppWin.Program.Main(String[] args)
The type initializer for 'System.Windows.Documents.TextElement' threw an exception.
at System.Windows.FrameworkElement..cctor()
The type initializer for 'System.Windows.Media.FontFamily' threw an exception.
at System.Windows.Media.FontFamily..ctor(String familyName)
at System.Windows.SystemFonts.get_MessageFontFamily()
at System.Windows.Documents.TextElement..cctor()
The type initializer for 'MS.Internal.FontCache.Util' threw an exception.
at MS.Internal.FontCache.Util.get_WindowsFontsUriObject()
at System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
at System.Windows.Media.FontFamily..cctor()
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()
如果我們通過URL啓動(在IE瀏覽器),或者通過桌面上的圖標,第一個應用程序,我們沒有得到異常和預期應用程序啓動。
整潔的事情是,無論我們首先推出什麼決定應用程序是否會啓動。因此,如果我們先用傳統方式啓動,那麼即使我們使用其他成功的URL或圖標啓動,我們也無法運行應用程序。爲了使它起作用,我們必須註銷並重新登錄並從URL或圖標開始。
如果我們第一次使用URL或圖標,我們從遺留應用程序從這個點開始沒有問題(直到我們註銷並返回)。
另一條信息是我們能夠以下面的方式模擬問題。如果我們使用「cmd.exe」輸入命令提示符並執行語句以從URL啓動,那麼我們會成功。但是,如果我們使用「command.com」輸入命令提示符並執行相同的語句,則會遇到破壞行爲。
我們認爲這是因爲Clipper中的遺留應用程序使用相當於command.com來創建shell來產生其他應用程序。我們已經嘗試了一堆黑客,比如有command.com運行cmd.exe或psexec然後執行,但似乎沒有任何工作。
我們對解決方法有一些想法(比如在啓動時啓動應用程序,所以我們強制從一個URL成功啓動,使所有後續啓動成功),但它們都是次優的,即使我們有很多控制我們的工作站。
爲了減少與權限相關的可能性,我們給出了啓動帳戶的管理權限(以及有區別的情況下的非管理權限)。
任何想法都將非常感謝。就像我說的,我們有一些解決方法,但我很樂意避開它們。
謝謝!
我要問一個愚蠢的問題,你的應用程序使用什麼版本的.NET Framework arget,並且該版本是否安裝在客戶端計算機上? – RobinDotNet 2010-04-06 23:35:16
框架是.NET 3.5 SP1。它安裝在客戶端上。此外,如果我們以正確的順序(即直接而不是通過遺產)啓動它,那麼應用程序運行良好,並且所有事情都按預期完成。 – jttraino 2010-04-07 04:37:47