前提
C#でsystem.windows.media.imagingのBitmapFrameを使用したプログラムを作成しました。
デバッグ環境では問題なく処理できたのですが、本番環境で動かしたところエラーとなり失敗してしまいます。
###原因
自分が調べた限りでは本番環境にpresentationcore.dllがないためだと考えているのですが、プログラムと同階層にコピーしても状況は変わりませんでした。
.NetFramework 4.8に含まれているものだと思っていたのですが、そうではないのでしょうか。
海外の記事ですが「https://stackoverflow-com.translate.goog/questions/16941520/exception-on-bitmapframe-create-bug-in-wpf-framework?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc」
の中の解決方法にBitmapFrame.csに関数を追加する?方法もあるようなのですが、方法がわかりませんでした。
お力をお借りできないでしょうか。
発生している問題・エラーメッセージ
2022/11/09 18:50:04 この処理を完了するために必要なイメージング コンポーネントが見つかりませんでした。 場所 System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle) 場所 System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache) 場所 System.Windows.Media.Imaging.BitmapDecoder.Create(Stream bitmapStream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption) 場所 System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy) 場所 System.Windows.Media.Imaging.BitmapFrame.Create(Stream bitmapStream)
該当のソースコード
C#
1 private void photoTopAndBottomCheck(string filePath) 2 3 { 4 5 BitmapImage bmpImage = new BitmapImage(); 6 7 FileStream stream = System.IO.File.OpenRead(filePath); 8 bmpImage.BeginInit(); 9 bmpImage.CacheOption = BitmapCacheOption.OnLoad; 10 bmpImage.StreamSource = stream; 11 BitmapFrame frame = BitmapFrame.Create(stream); 12 BitmapMetadata metaData = (BitmapMetadata)frame.Metadata; 13 14 }
補足情報(FW/ツールのバージョンなど)
デバッグ環境:Widows pro 10、.NetFramework 4.8
本番環境:Windows Server 2019、.NetFramework 4.8
回答1件
あなたの回答
tips
プレビュー