Casting problem
-
I have the following code: /* In myprog.exe - I get an exception here */ catch (LdapException e) { string port = String.Format("{0}", ldapPort); m_log.LogMessage("strCantConnectToLdap", "strCantConnectToLdapTitle", e, ldapHost, port, loginDN); return false; } /* which calls this in my.dll */ public DialogResult LogMessage(string headerTag, string messageTag, LdapException e, string sub1, string sub2, string sub3) { string [] subParams = new string[3]; subParams[0] = sub1; subParams[1] = sub2; subParams[2] = sub3; return FullLogMessage(headerTag, messageTag, MigError.ErrorLevelE.ERROR, e, subParams); } /*which call this in my.dll */ public DialogResult FullLogMessage(string messageTag, string headerTag, MigError.ErrorLevelE level, Exception exception, string [] subParams) { // Rework for different types of exceptions if (exception != null) { if (exception is LdapException) /* should succeed but doesn't - why?*? :confused:*/ { LdapException e = exception as LdapException; format = LoadString("strLdapExceptionFormat"); string ldapErrorString = MapLdapError(e.ResultCode); exceptionMessage = String.Format(format, e.LdapErrorMessage, e.resultCodeToString(), ldapErrorString, e.StackTrace); } else ... } } Any ideas? BRCKCC