したがって、画像をDLLから取り出して画像コントロールに入れると、BitmapImageになります。それをdllにパッケージ化するには、イメージに変換する必要があります。どのように私はそれをイメージに変換することができ、どのように私はdllにそれを再パッケージ化できますか?これはcpで書かれたwpfのすべてです。ビットマップを画像に変換する
private void compileDLL_Click(object sender, RoutedEventArgs e)
{
string sourcePath = Directory.GetCurrentDirectory() + "\\PCAngelResources.dll";
//destination path
string dllname = textBox1.Text + "_PCAngelResources.dll";
string targetPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string destFile = System.IO.Path.Combine(targetPath, dllname);
System.IO.File.Copy(sourcePath, destFile, true);
//lstImages = new Dictionary<string, Bitmap>();
//string filename = "PCAngelResources.dll";
Assembly pcangdll = Assembly.LoadFile(sourcePath);
System.Globalization.CultureInfo culture = Thread.CurrentThread.CurrentCulture;
ResourceManager rm = new ResourceManager("PCAngelResources.DynResources", pcangdll);
rs = rm.GetResourceSet(culture, true, true);
ResourceWriter writer = new ResourceWriter(destFile);
foreach (DictionaryEntry resource in rs)
{
resources.Add((string)resource.Key);
if (resource.Key.Equals("Branding") || resource.Key.Equals("Advertising"))
{
if (resource.Key.Equals("Branding"))
{
writer.AddResource("Branding", image5.Source);
//System.Object obj = rm.GetObject((string)resource.Key);
//lstImages.Add((string)resource.Key, (Bitmap)obj);
}
else
if (resource.Key.Equals("Advertising"))
{
writer.AddResource("Advertising", image6.Source);
}
}
}
writer.Generate();
System.Windows.MessageBox.Show("Done", "Process Finished", MessageBoxButton.OK, MessageBoxImage.Asterisk, MessageBoxResult.OK);
}
私は新しいdllファイルを作るためにwriter.Generate()を行うと、私は次のエラーを取得する:型「System.Runtime.Serialization.SerializationException」の 未処理の例外がmscorlib.dllは
で発生しました追加情報:Assembly 'PresentationCore、Version = 3.0.0.0、Culture = neutral、PublicKeyToken = 31bf3856ad364e35'のアセンブリ 'System.Windows.Media.Imaging.BitmapFrameDecode'にシリアル化可能とマークされていません。
いくつかのサンプルコードはありますか? –
問題をより明確に定義してください。 –
コードを更新すると、既存のイメージをイメージのユーザーと置き換える方法に関する新しいアイデアが選択されますか?そして、どのようにしてgenerate()エラーを修正するかについて考えてください。 – Jake