2009-04-10 7 views

답변

7

이것은 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)); 
       } 
      } 
     } 
+0

; 나는 속임수로 대답을 지울거야 ... –

+0

전체 어셈블리가 com으로 표시되어있어 고마워. –

관련 문제