.NET에서 Sens Events Catch, Guid 속성 없음
문제
나는 따르고있다 이 기사 COM을 통해 Sens 이벤트를 등록하지만, 나는 무언가를 놓친 것 같습니다. 나는이 기사가 다음과 같이 쓴 구독 메소드 메소드라고 부릅니다.
EventSystemRegistrar.SubscribeToEvents("ManagedSENS EventSubscriber", "ManagedSENS.SensLogonInterop", subscriptionViewerID, this, typeof(SensLogon));
이 방법이 호출되는 것으로 연결됩니다.
private static String GetInterfaceGuid(Type type)
{
Object[] attributes = type.GetCustomAttributes(typeof(GuidAttribute), true);
return String.Format("{{{0}}}", ((GuidAttribute)attributes[0]).Value);
}
문제는 글쓰기에 조언하는 Senslogon 클래스가있는 유형이지만, 그 속성은 없으므로 그 방법이 예외를 던지는 것입니다. 실제로 Guidattributes 인 유일한 속성은이 수업에 적합하며 Senslogon 클래스와 관련이 없습니다 (적어도 내가 알 수있는 한).
[ComImport, Guid("4E14FBA2-2E22-11D1-9964-00C04FBBB345")]
class EventSystem { }
[ComImport, Guid("7542E960-79C7-11D1-88F9-0080C7D771BF")]
class EventSubcription { }
[ComImport, Guid("AB944620-79C6-11d1-88F9-0080C7D771BF")]
class EventPublisher { }
[ComImport, Guid("cdbec9c0-7a68-11d1-88f9-0080c7d771bf")]
class EventClass { }
아마도 여기에 뭔가를 놓치고 있었을까요? 이 수업이나 무언가에서 파생해야 했습니까? Senslogon 클래스가 표시되지만 이러한 속성은 없습니다.
COM 이벤트 등록과 비슷한 일을 한 사람이 있습니까?
해결책 2
나는 그것을 알아. 나는 typeof (senslogon)를 EventsyStemregistrar.subscribetoevents로 전달했습니다. 바보 나.
다른 팁
전화를 가정하고 있기 때문에 코드가 안전하지 않다고 생각합니다. type.GetCustomAttributes(...)
확인하지 않고 일했습니다 .... 나는 이것을 try
/catch
무슨 일이 일어나고 있는지 확인하고 예외를 검사하기 위해 차단하십시오 ...
private static String GetInterfaceGuid(Type type) { string sGuid = string.Empty; try{ Object[] attributes = type.GetCustomAttributes(typeof(GuidAttribute), true); if (attributes != null && attributes.Length >= 1){ sGuid = String.Format("{{{0}}}", ((GuidAttribute)attributes[0]).Value); }else{ // FAIL! } }catch(System.Exception up){ throw up; } return sGuid; }
그랬어 ess.dll
전혀 등록 하시겠습니까? 수동으로 등록해야 할 수도 있습니까? 해당 클래스 ID의 HKEY_CLASSES_ROOT에 대한 레지스트리를 확인하고 TypLib ID를보십시오. regsvr32 ess.dll
어디에서나 DLL 파일이 현재 폴더에있는 곳.
이것이 도움이되기를 바랍니다.