简体   繁体   中英

WPF SplashScreen class can not locate the embedded image

I'm trying to display splash screen for my WPF application . Based on some condition I have to load one of two images I have created. So i have to use SplashScreen class instead of setting a static image as flashscreen . Which is easy and works in my case.

I'm doing something like following,( I have set the both images as Embedded Resource )

string splashImage = string.Empty;
if (Condition)
  {
    splashImage = "ApplicationType1.png";
  }
else
  {
    splashImage = "ApplicationType2.png";
  }

SplashScreen screen = new SplashScreen(splashImage);
screen.Show(true);

Which gives me exeception,

Cannot locate resource ApplicationType1.png

Finally i figured it out,

Problem was with the .png image i have added. Still i have no clue why it couldn't load that specific image. I just got the .jpg image and it works fine.

And it works with both build actions Embedded Resource or Resource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM