나는 이것이 가장 좋은 하나 아니라고하지 확신하지만 당신은 이런 식으로 뭔가를 시도 할 수 있습니다 : -
Assembly ambly = Assembly.LoadFile(pathToDll);
또는
BitMap bitMap;
// where "ns" is the default namespace of the resource project
using (Stream resourceStream = ambly.GetManifestResourceSream("ns.image.jpg"))
{
bitMap = BitMap.FromStream(resourceStream);
}
예 : -
interface IThemeResourceProvider
{
Stream LoadBigLogo();
Stream LoadSmallLogo();
}
을
그런 다음 리소스 라이브러리에 해당 인터페이스를 구현하십시오.
public class ThemeResourceProvider : IThemeResourceProvider
{
public Stream LoadBigLogo()
{
Assembly ambly = Assembly.GetExecutingAssembly();
return ambly.GetManifestResourceStream("namespace.image.jpg");
}
(...)
}
마지막으로, 인스턴스화 대신 기본 응용 프로그램에서 직접 자원을로드하는 IThemeResourceProvider 지금 당신이 목록에서 IEnumerable을 가지고있는 리소스 라이브러리
Assembly assembly = Assembly.LoadFile(pathToDll);
var results = from type in assembly.GetTypes()
where typeof(IThemeResourceProvider).IsAssignableFrom(type)
select type;
에서 발견. 일반적으로 하나만 가질 수 있지만이 방법을 사용하면 여러 리소스 세트를 호스팅하고 동일한 리소스 DLL에 여러 IThemeResourceProviders를 구현할 수 있습니다. 예 : 각 IThemeResourceProvider를 특성으로 식별하거나 다양한 구현에서 사용자 정의 [Attribute] 데코레이션을 사용하여 식별하십시오. 알아낼 수 있도록 나머지는 네가 맡길거야. 이것은 내가 누군가로부터받은 코드가
BitMap bitMap;
using (Stream resourceStream = provider.LoadBigLogo())
{
bitMap = BitMap.FromStream(resourceStream);
}