locked
About type cast RRS feed

  • Question

  • Hey guys,

    values from Properties, like Conversation.Properties, are of type Object, so how can I know the real type of those values without any help from SDK?

    I came to get exception messages such as"invalid cast from System.Int32 to char[]", does that mean that the value I acquited from IDictionary<XXXEnum, Object> is of type System.Int32?

    Thanks,

    Joy

    Friday, July 20, 2012 7:49 AM

Answers

  • Joy,

    A quick way to find the actual type of the object you get when you reach into the conversation property bag is to use reflection to do the following:

    #if DEBUG
                    object myObject = e.Conversation.Properties[ConversationProperty.ConferenceDisclaimer];
                    MessageBox.Show(myObject.GetType().Name);
    #endif
    
    The string value of the Name property is the class name from the Lync client API.

    John Austin Senior Programming Writer Microsoft

    Friday, July 20, 2012 7:21 PM

All replies

  • Joy,

    A quick way to find the actual type of the object you get when you reach into the conversation property bag is to use reflection to do the following:

    #if DEBUG
                    object myObject = e.Conversation.Properties[ConversationProperty.ConferenceDisclaimer];
                    MessageBox.Show(myObject.GetType().Name);
    #endif
    
    The string value of the Name property is the class name from the Lync client API.

    John Austin Senior Programming Writer Microsoft

    Friday, July 20, 2012 7:21 PM
  • Got it,

    thank you!

    Monday, July 23, 2012 8:15 AM