dimanche 17 avril 2016

Create Object from UnmanagedMemoryStream

If I have an UnmanagedMemoryStream object, How can I get the object from it. I was working on below code, where I am trying to get a Resource (rd.xaml) from an Assembly :

string address = @"WpfControlLibrary1.dll";
        Assembly skinAssembly = Assembly.LoadFrom(address);
        string name = skinAssembly.GetName().Name +".g";
        var manager = new ResourceManager(name, skinAssembly);
        ResourceSet rs = manager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

        UnmanagedMemoryStream stream = (UnmanagedMemoryStream)rs.GetObject("rd.baml", true);

Now I'm not able to deserialize the content of Stream into a .net Object(which is a Resource Dictionary in above case). How can I do this?

PS: BinaryFormatter is throwing an exception while Deserialize operation.





Aucun commentaire:

Enregistrer un commentaire