empty sharepoint user profile property throw an exception

Posted by James123 on Stack Overflow See other posts from Stack Overflow or by James123
Published on 2010-04-14T23:10:39Z Indexed on 2010/04/14 23:13 UTC
Read the original article Hit count: 231

Filed under:

I have a user profile property. user not assigned any value that property. If I use below code. It is thorwing exception " object reference not set to an instance of an object "

userprof["OptOut"].ToString()

I tried all types like

if (userprof["OptOut"] != null)
          OR
if(userprof["OptOut"].Value != null)

nothing worked out for me.

Here userProf object has value. userprof["OptOut"].Value is null

How to handle this?

© Stack Overflow or respective owner

Related posts about sharepoint