그래서 이미지를 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);
}
내가 writer.Generate을 수행 할 때() 나는 다음과 같은 오류가 새 DLL로 만들려면 형식 'System.Runtime.Serialization.SerializationException'처리되지 않은 예외가 mscorlib.dll
에서 발생 을 추가 정보 : 어셈블리 'PresentationCore, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'에 'System.Windows.Media.Imaging.BitmapFrameDecode'유형이 직렬화 가능으로 표시되어 있지 않습니다.
일부 샘플 코드? –
문제를보다 명확하게 정의하십시오. –
코드를 업데이트하면 기존 이미지를 이미지 사용자가 교체하는 방법에 대한 새로운 아이디어가 있습니까? 그리고 어떤 생각을 어떻게 generate() 오류를 수정합니다. – Jake