I can't be the only one that has experienced something like this.
I made a module with an embedded resource. An icon. During the module Initialize method, I read that file into a stream. As soon as I read that stream into an Image control, the module stops initializing. No error. Nothing.
I have not been able to figure out anything or make any headway.
The only thing I can imagine is that somehow reading the stream messes with something in the module initialization process, but I can't imagine what that would be. I could test this if I knew how to hook into the event system to try the stream read
after initialization is complete. But I don't see any way to do this. So two questions here:
Has anyone used embedded resources successfully in a module?
Is there a ModuleInitializedEvent or some way to make one myself?
Mar 18, 2010 at 3:25 PM
Edited Mar 18, 2010 at 3:26 PM
For anyone that cares to know, I figured out my problem. I don't know why but opening an 'embedded resource' into a stream and reading it into a bitmap and then converting it into a System.Windows.Controls.Image will stop a module from loading.
It doesn't give an error. It just silently stops. But obviously, since this is WPF, we don't necessarily want to be using Windows Forms solutions and converting the output to WPF objects anyway. For WPF, we use a build action on the file
of 'Resource' not 'Embedded Resource'. But the
http://msdn.microsoft.com/en-us/library/aa970069.aspx page on building a Pack Uri didn't seem to help at all. The code couldn't find the 'Resource' no matter how many times I edited the string. I have since come to find out that the MSDN page
seems to be completely wrong. In MSDN, the Pack Uri string looks something like this:
But it didn't work and I tried all kinds of variations. It just didn't work. This works and I got it from the Petzold WPF book.
The only difference is two commas instead of three. I have no idea how that is possible because that page has three commas in every single example of a Pack Uri.
I don't really see how this could be so wrong, so if someone else has an insight, please share it. Also, it would be nice to know why the module quits loading when the bitmap from stream gets converted to an Image control.