2016-04-07 1 views
0

私はスプラッシュ画面を表示するためにSystem.Windows.SplashScreenを使用しています。奇妙な問題があります。イメージが別のフォルダにある場合、アプリケーションはIO.IOException(resurce not found)を発生させます。 私はすべてのビルドタイプを試して、画像は全く同じプロパティを持っています。SplashScreenによってIO.IOExceptionが発生する

public class DinSplashScreen 
{ 
    private const int SPLASH_SCREEN_FADING_OUT_DURATION = 1000; 

    private System.Windows.SplashScreen _splash; 

    public DinSplashScreen() 
    { 
     // this works 
     _splash = new System.Windows.SplashScreen(@"splash.jpg") 

     // this crashes 
     _splash = new System.Windows.SplashScreen(@"..\Images\splash.jpg"); 
    } 

    /// <summary> 
    /// Shows the splash 
    /// </summary> 
    public void Show() 
    { 
     if(_splash != null) 
     { 
      // here the exception occurs 
      _splash.Show(true, true); 
     } 
    } 
+0

このように使用します_splash = new System.Windows.SplashScreen(@ ".. \ .. \ Images \ splash.jpg"); – rashfmnb

+1

あなたのフォルダ構造を投稿してください。イメージが本当にそのフォルダにあることを確認してください。 –

+0

パス*が既存のイメージを指していない可能性がありますか?アプリケーションのフォルダの外にあるImageフォルダを探しているのはなぜですか? –

答えて

0

このlinkは、あなたのプロジェクトにRESXファイルを追加し、それを使用する必要があり、このためにあなたに参考になるリソースファイルとそれを使用するように画像を追加します。

+0

埋め込みリソースとしてresource.resxに追加しました。私は "コンパイル時に"プロパティも試しました。しかし、同じエラーが発生します。 – ChrisPlusPlus