【发布时间】:2015-05-28 08:25:00
【问题描述】:
我有一个带有 ResourceDictionary 的 DLL。 如果我从 WPF 应用程序调用这个字典,一切都会正常工作。 但是,如果我从控制台应用程序调用 dict,我会收到错误“无法识别 URI 前缀”
ResourceDictionary res = new ResourceDictionary();
try
{
res.Source = new Uri("ClassLibrary1;component/SomeDict.xaml", UriKind.Relative);
var l = res["SomeKey"];
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
【问题讨论】:
-
尝试指定full
Uri(或如何调用):click。 -
@Sinatr 现在我有这个错误 Invalid URI: invalid port。我用这个: res.Source = new Uri("pack://application:,,,/ClassLibrary1;component/SomeDict.xaml");我尝试将 ResourceDictionary 添加到 ConsoleApp 中。当我调用它时,我得到了同样的错误。
标签: c# wpf uri resourcedictionary