0
我正在處理版本歷史記錄對話框,並且我創建了一個樣本來測試它。不過,看來,該樣品找不到HTML文件:Application.GetResourceStream拋出IOException
var dlg = new VersionHistoryDialog();
var uri = new Uri(@"pack://application:,,,/VersionHistory.html", UriKind.Absolute);
var source = Application.GetResourceStream(uri).Stream; // This line throws the error
dlg.Stream = source;
var result = dlg.ShowDialog();
label1.Content = result;
這條線在上面的代碼拋出這個錯誤:
System.IO.IOException was unhandled
Message=Cannot locate resource 'versionhistory.html'.
Source=PresentationFramework
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream()
at System.Windows.Application.GetResourceStream(Uri uriResource)
....
所以....我該怎麼辦?該文件被命名爲「VersionHistory.html
」,並且它在與xaml.cs
文件相同的文件夾(「視圖」)中詢問它。
所以/ SilverlightApplication;部分將是項目的名稱?假設我在文件夾'Views'下的Project'XYZ'中有文件。我將如何進入? – Entity 2010-10-22 12:46:59