4
.NET에서 볼 수있는 모든 .NET 클래스와 해당 ProgID를 찾기 위해 프로그램을 작성하고 싶습니다. 이 작업을 수행하는 가장 좋은 방법은 무엇입니까?.NET 어셈블리에서 ProgID 가져 오기
.NET에서 볼 수있는 모든 .NET 클래스와 해당 ProgID를 찾기 위해 프로그램을 작성하고 싶습니다. 이 작업을 수행하는 가장 좋은 방법은 무엇입니까?.NET 어셈블리에서 ProgID 가져 오기
이것은 ClassId를 대신 PROGID를 얻고, 온 회중이 보이지 표시된 경우에도 작동합니다 : 그것처럼
Assembly assembly = Assembly.LoadFile("someassembly.dll");
bool defaultVisibility;
object[] assemblyAttributes = assembly.GetCustomAttributes(typeof(ComVisibleAttribute),false);
if (assemblyAttributes.Length == 0)
defaultVisibility = false;
else
defaultVisibility = (assemblyAttributes[0] as ComVisibleAttribute).Value;
foreach(Type type in assembly.GetTypes())
{
bool isComVisible = defaultVisibility;
object []attributes = type.GetCustomAttributes(typeof(ComVisibleAttribute),true);
if (attributes.Length > 0)
isComVisible = (attributes[0] as ComVisibleAttribute).Value;
if (isComVisible)
{
attributes = type.GetCustomAttributes(typeof(ProgIdAttribute),true);
if (attributes.Length >0)
{
Console.WriteLine(String.Format("Type {0} has ProgID {1}",type.Name,(attributes[0] as ProgIdAttribute).Value));
}
}
}
; 나는 속임수로 대답을 지울거야 ... –
전체 어셈블리가 com으로 표시되어있어 고마워. –