views:

427

answers:

1

Can I use the built in WPF splash screen functionality in a WinForms project compiled under .NET 3.5 SP1 VS2008?

+1  A: 

Yes you can, but it's kinda fragile and not very straightforward.

The SplashScreen class looks for an AssemblyName + ".g" resource file. To create it, you need to include a "g.resx" file in your project. The root namespace as set in project properties must be the same as the assembly name.

This resource file needs to contain the image as a MemoryStream, NOT a System.Drawing.Bitmap! Perhaps there's an easier way, but I just included the file and then manually changed the entry to look like this:

<data name="splash.png" type="System.Resources.ResXFileRef, System.Windows.Forms">
  <value>Splash.png;System.IO.MemoryStream, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>

Then just include the following lines in your Main method:

var splash = new SplashScreen("Splash.png");
splash.Show(true);

Hope that helps.

jachymko