이 질문은 this article의 확장입니다.대소 문자를 구별하는 언어를 사용하는 동안 COM에서 대소 문자를 구분하지 않는 충돌 이름을 해결하는 방법
같은 경우에 나는 ProgID
으로 WMP ActiveX의 인스턴스를 만들었습니다.
protected const string WMP_PROG_ID = "WMPlayer.OCX.7";
private dynamic _wmp;
protected virtual bool init(){
try{
_wmp = Activator.CreateInstance(Type.GetTypeFromProgID(WMP_PROG_ID));
}
catch{ return false; }
return connectEvent();
}
MSDN 문서에 따르면, Error
wmplayer를 이벤트 및 객체의 속성 error
있다. 그래서 이런 방식으로 이벤트를 첨부하려고합니다. 내가 주석 //_wmp.Error += new Action(_wmp_ErrorEvent)
을 유지하는 경우
protected bool connectEvent(){
try{
_wmp.PlayStateChange += new StateHandler(_wmp_PlayStateChange);
//_wmp.Error += new Action(_wmp_ErrorEvent);
}
catch { return false; }
return true;
}
protected void _wmp_PlayStateChange(WMPlayerState state){
//do something I like
}
protected void _wmp_ErrorEvent(){
//do some error handling
}
, 에는 컴파일 오류가 없습니다 및 PlayStateChange
작품 꽤 좋은.
그러나 주석 기호를 제거하면 런타임 예외가 있습니다. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: can not apply operator "+=" between 'System.__ComObject' and 'System.Action'
COM에서 대소 문자를 구분하지 않으므로 두 개의 "오류"가 충돌하는 것 같습니다. 어떻게 해결할 수 있습니까? 내 목표는 AxWindowsMediaPlayer를 사용하지 않고 "Error"이벤트에 첨부하는 것입니다.
감사합니다. tlbimp를 사용하여 wmp.dll을 변환하고 분해하려고했습니다. 그러나 'Error' 속성 만 있지만'error' 이벤트는 없습니다. 나는 MS 도구의 변환이 충돌 문제를 처리하지 않는다고 생각한다. –