Lucy de Boer
 

Object reference not set to an instance of an object with custom workflow

23

May

A few months ago I was experiencing a rather annoying bug, a ‘Server Error in '/' Application’ when using my custom workflow on a publishing pages document library in MOSS 2007. The issue was: If my custom workflow is applied to a publishingpage, when the user enters the document library and selects ‘Edit Properties’ or opens the page for editing the server error pasted below occured. When check out is disabled on the document library the error does not occur when editing properties, However the user still cannot edit the page through ‘Edit Page’. The user can check in and check out the page without any problems.

After some testing I noticed this error occurs with any custom workflow, even the samples provided in the ECM Starter Kit so I figured the problem cannot be my code. A very similar error (Value cannot be null. Parameter name: s) also occurs when using the standard provided ‘Disposition Approval’ workflow, the stack trace of these two are almost identical:

Stack Trace snip:

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.SharePoint.Publishing.Internal.WorkflowUtilities.GetAssociationDataValue(CachedWorkflow workflow, String xmlNodeName) +124
M
icrosoft.SharePoint.Publishing.WebControls.ConsoleDataSource.EnsurePageNotInLockingWorkflowIfInEditMode() +121
Microsoft.SharePoint.Publishing.WebControls.ConsoleDataSource.LoadDataSource() +150

 

Here’s a screendump of the full Error (click to enlarge):

After discussing the issue with Microsoft and placing a call, yesterday the final answer came through in the form of a hotfix, related to KB Article Number 933819. The knowledgebase Article seems to be taken offline but yes! It is the answer. I applied the hotfix to my server and instantly the error has disappeared. My workflow is working beautifully now.

So, if you are experiencing the same bug, give Microsoft Support a call and mention KB 933819.

Lucy de Boer schreef

Comments (6)

Lucy de Boer

Randy Jackson

27-05-2007 12:58

Thanks Lucy! You saved me a lot of time wondering what the heck I was missing>

shashwat chandra

31-05-2007 06:16

Hi,

I am facing similar issues.

When I try to attach the workflow to the item in the document library, the workflow status shows “Error occurred”. I searched in the internet and find out that this occurs when there is the problem in the code (http://blogs.msdn.com/sharepoint/archive/2006/11/30/developing-workflows-in-vs-part-6-deploy-and-debug-your-workflow.aspx?CommentPosted=true#commentmessage).

Then I tried to comment all the code in below eventsà

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) {}

private void codeActivity1_CodeHandler(object sender, EventArgs e) {}

After that I tried to run the workflow, the status is shown as “Completed”. This is when there is no code in the above events.

After this then I modified the events within the below codeà

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)

{
workflowId = workflowProperties.WorkflowId; //initialize the id


}

private void codeActivity1_CodeHandler(object sender, EventArgs e)

{

System.IO.Stream strm = new System.IO.FileStream("c:\\shashwfl.txt", System.IO.FileMode.OpenOrCreate);

workflowProperties.Web.Lists["Tasks"].WriteRssFeed(strm);

}



Again I got the same error as “Error occurred”. I think some important code is missing in the above events, but don’t know what.

Can you have any clue regarding this?

Thanks
Shash

shashwat chandra

31-05-2007 06:19

do we need to provide some fix here?

Thanks,
Shashwat

H.Y.

05-06-2007 22:22

I don't suppose anybody knows where the KB Article has gone? I'm encountering the same issue (NullReferenceException when editing a page) but the KB article has gone missing.

Thx,
H.Y.

Lucy

06-06-2007 06:54

Hello, sorry for my late reply, i had a short holiday. :)

Shashwat, in regards to your comment, this does not relate to the bug above, but seems to be code related. please try to debug the newly added code, this should give you an error description in visual studio when the exception occurs.

H.Y., In relation to the KB article, as stated above the article has been taken offline, probably it is still in review at Microsoft or not yet fully tested, they do not release the article for the public until it's fully tested and approved. but if you give Microsoft Support a call and mention the number they will provide you with the fix.

Good luck!

Shashwat

27-06-2007 09:11

Yes Lucy,

You were very much rite.After writing lot of codes in Sharepoint i found if your custom workflow after running shows status as "Error Occured", it certainly means that something is wrong in the code you have written.Please reveiw your code if the status is "Error Occured".

Also I have one more problem now.

I have created an App.config file for my Workflow.When builded it gives me a file name as Workflow.dll.config.
I need to add this App.config in the GAC so that when the Workflow DLL is in GAC it looks at the appropriate App.config in GAC too.

Problem is that App.config is not getting added to the GAC.
any solutions?

Regards,
Shashwat

Comments are closed.

Zoeken

Categorie

Archief


Sign In