-
DLL Ressource 에서 BitmapImage 불러오기 Method.NET/C# Basic 2013. 1. 11. 00:02반응형
1. 외부 DLL Ressource 리플렉터 =>
2. 코드
/// <summary>
/// name : GetDllToBitmapImageResource /// desc : BitmapImage load of resource /// author : 전광식 /// create Date : 2013-01-10 오후 7:56:23 /// update date : 2013-01-10 오후 7:56:23 , 수정개요
/// </summary> /// <param name="assemblyName">AssemblyName</param> /// <param name="resourceUri">resourceUri</param> /// <returns></returns> public BitmapImage GetDllToBitmapImageResource(string assemblyName, string resourceUri) { Assembly assembly = Assembly.LoadFrom(System.Environment.CurrentDirectory + @"\" + assemblyName); CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture; string resourceName = assembly.GetName().Name + ".g"; ResourceManager resourceManager = new ResourceManager(resourceName, assembly); try { ResourceSet resourceSet = resourceManager.GetResourceSet(culture, true, true); var resource = resourceSet.Cast<DictionaryEntry>().FirstOrDefault(x => x.Key.ToString() == @resourceUri).Value; if (resource.GetType().BaseType == typeof(Stream)) { Stream stream = resource as Stream; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.BeginInit(); bitmapImage.StreamSource = stream; bitmapImage.EndInit(); return bitmapImage; } else { return new BitmapImage(); } } finally { resourceManager.ReleaseAllResources(); } }using =>
img이미지.Source = GetDllToBitmapImageResource("HIS.UI.Design.Themes.dll", "images/main/nopicturefemale.png");
반응형'.NET > C# Basic' 카테고리의 다른 글
IIS HTTPS 세팅하기 및 C# 사설 SSL 인증서 호출 사용하기 OPENSSL 사용하기 (0) 2023.03.14 C# CallerMemberNameAttribute Class 소개 (0) 2016.02.29 C# Custom Sort Null 널값이 제일 아래로 IComparer IComparable (2) 2013.08.23 Visual Studio 2005의 원격 디버깅 설정(http://www.hoonsbara.com/) (1) 2010.06.14 [C#] String.Format 을 이용한 문자정렬 왼쪽 오른쪽 가운데 | String alignment Left Right Center (0) 2010.03.20 [C#] char[] + char[] = char[]?? | char[] Merge (0) 2010.02.09 [C#] Thread를 정복해 보자 (0) 2010.02.06 사용예) StringCollection 과 string[] int[] converterMethod (0) 2010.02.02