using “Replace” on the string clientNameStr causes an “Object Reference Not Found” error.
// Get client name
clientName = currentUser.GetValue("ClientName");
string clientNameStr = (string)clientName;
string clientURLStr = string.Empty;
clientURLStr = clientNameStr.Replace(' ', '-');
// clientURLStr = "ST9215-Stanic-Parts-Ltd";
If I substitute in the commented out string (and comment out the existing one) it works fine, so it must be something to do with the replace function, but what? Have tried it with both ” and ‘ quote marks, to the same result.
Any help would be greatly appreciated.
Thanks, Oli.
That basically shows that
currentUser.GetValue("ClientName")is returning a null reference1.We can’t tell what
currentUser.GetValue("ClientName")does, but there are two options:1 It’s possible that it’s returning a non-null reference and using a user-defined conversion to string in the next line which returns null – but unlikely. We can’t tell for sure because we don’t know the type of the
clientName.