저는 개발중인 VBA 도구에서 일부 .net 서비스에 연결해야합니다. 함수를 사용하여 캐시 된 인스턴스를 반환하거나 아직 생성되지 않은 경우 새 인스턴스를 만듭니다. 아무것도 (예 : 밖으로 연결 시간으로) 객체와 잘못되면VBA - 예외를 발생시키기 전에 System.ServiceModel.Channels.ServiceChannel 오류 상태 확인
, 내가 그것을 사용하려고 다음에, 나는 오류를
통신 개체, System.ServiceModel.Channels.ServiceChannel를 얻을 수 오류 상태이므로 통신에 사용할 수 없습니다.
이 오류는 웹 전체에서 팝업으로 표시되지만 try-catch 블록이있는 적절한 언어로 표시됩니다.
캐시 된 인스턴스를 사용하고 "On Error Goto"문에서이 오류를 처리 할 때이 오류가 발생할 때까지 기다리는 대신 캐시 된 개체를 검색 할 때 오류가 발생하지 않도록하고 싶습니다. 어디서나이 객체 모델을 찾을 수 없었고 초기화 된 객체를 감시하는 설정 만 보여줍니다. 객체가 오류 상태인지 확인하기 위해 검색 할 때 사용할 수있는 속성이나 테스트는 무엇입니까? 오류가 발생한 경우 다른 곳
Private Function GetMRLDIntegrationService() As Object
Const ServiceAddress = "service:mexAddress=""net.tcp://hydfwdvweb001/Integration/MrldIntegrationService.svc/Mex""," & _
"address=""net.tcp://hydfwdvweb001/Integration/MrldIntegrationService.svc/""," & _
"contract=""IMrldSimplexIntegration"", contractNamespace=""http://tempuri.org/""," & _
"binding=""SimplexIntegration"", bindingNamespace=""http://tempuri.org/"""
Static cachedInstance As Object
If Not cachedInstance Is Nothing Then
''//If *DETECT ERROR STATE HERE* Then Set cachedInstance = Nothing
End If
If cachedInstance Is Nothing Then Set cachedInstance = GetObject(ServiceAddress)
If cachedInstance Is Nothing Then Err.Raise 1, , _
"The MRLD server did not respond to the request to provide the service object."
Set GetMRLDIntegrationService = cachedInstance
End Function
는 다른 방법으로,이이며,이는 우아하게 에러를 처리하기 위해 너무 늦기 때이다 : 도움
더미 요청이 각 통화 시간을 두 배로, 일반 하나로 처리 할만큼 오래 걸리기 때문에이 작업을 수행 할 수 없습니다. – Alain