I have a DLL with a ResourceDictionary. If i call this dict from WPF app, all will work correctly. But if i call a dict from console app, i wiil get an error "The URI prefix s not recognized"
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);
}
Its need to configurate Uri. This articles will help in it.
http://www.yac.com.pl/mt.texts.wpf-tests-pack-uri-handling.en.html
http://compilewith.net/2009/03/wpf-unit-testing-trouble-with-pack-uris.html
UriFormatException : Invalid URI: Invalid port specified
I used this
if (!UriParser.IsKnownScheme("pack"))
{
Application app = Application.Current;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.