Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using sequential workflow 2010. I created a folder named GeneralLeave under library.

When I execute the following my code I got error in line spfolder.

My code is:
C#
 if (workflowProperties.Item["Action"].ToString() == "Separation" && workflowProperties.Item["Effective Date"].ToString()!="")
                {
                    
                    SPFolder myLibrary = SPContext.Current.Web.Folders["GeneralLeave"];
}

Thanks

Manohar
Posted
Updated 28-Oct-13 22:39pm
v2

We can't tell you exactly why you get the problem - it's likely that the actual fault is elsewhere in your code and is only showing up here.
But basically, what is happening is that one of the elements to the left of a "." is null.
For example:
C#
string s = a.b.c.d.ToString();
if a is null, you will get the error.
if a is a value, but a.b is null, you will get the error.
if a.b is a value, but a.b.c is null...

You get the idea.

Put a breakpoint on the line above the one giving the error and use the mouse to hover over each part in turn - find which one is null and you can start looking for why your code has let it be null.

Sorry, but it's over to you and the debugger, I'm afraid.
 
Share this answer
 
Agreed with OriginalGriff[^].

My advice to you is use
C#
Convert.ToString(YourString);
instead of
C#
YourString.ToString();


Here Convert.ToString(YourString) will handle if YourString is NULL and won't throw exception.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900