I have a WPF Application that contains a xaml file marked as ressource (buildprocess). During runtime I can load and access that file using following code:
Uri uri = new Uri("some.xaml", UriKind.Relative);
System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(uri);
System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
Border savedBorder = reader.LoadAsync(sri.Stream) as Border;
Moving the functionality and xaml file into a class library and mark "some.xaml" it as resource, the above code fails with IOException "The resource "some.xaml" could not be found". That sounds logically because I cannot successfully access Application.GetResourceStream
inside a class library.
System.Reflection.Assembly
.GetExecutingAssembly()
.GetManifestResourceStream("some.xaml") ;
returns null
.
What is the correct way to Access such a file inside a dll?