C# Archives

November 28, 2007

DisconnectedContext was detected

Context 0x1fa878 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM
Wow, look at that jargon. Anglais, si'l vous plait. My humble attempt, can you do better?
Dude, remember when I told you that running multiple chunks of code in parallel, i.e., multi-threading, was evil? Remember how you didn't listen to me? Well, I noticed that you are manipulating some stuff from chunk one in chunk two. What are you going to do if chunk one suddenly ends and the stuff disappears?

January 16, 2009

"Image format is unrecognized" when setting WPF Window Icon

Vista allows embedding 256x256 png images inside of .ico files. This can be generated, for example, by an application such as IcoFX. Unfortunately, at least as of .NET 3.0, the WPF Window Icon cannot accept this. The problem does not lie in the IconBitmapDecoder, but appears to lie in the Window code. To set the Icon property in code, we can do the following:

IconBitmapDecoder ibd = new IconBitmapDecoder(s, BitmapCreateOptions.None, BitmapCacheOption.Default);
this.Icon = ibd.Frames[0];

Where "s" is your .ico stream. If you have a Vista-style .ico file, setting Icon will trigger the "image format is unrecognized" error. The only way to resolve this is to generate the .ico without the Vista images*.


Now, take a cleansing breath, smile, and get back to work.

*MSDN discussion.

About C#

This page contains an archive of all entries posted to Tim's Journal in the C# category. They are listed from oldest to newest.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.35