Unable to retrieve Sharepoint List Item With Workflow attached (In Progress, completed etc.) on it -


i using share point 2010, , using linq generated spmetal.exe. facing weird issue mentioned below sequence:

1: inserted new item (xx) in list (listname) 2: on insertion workflow starts , item (xx) status becomes "in progress" in items window. 3: if access row linq, threw exception "specified cast not valid" [nullreferenceexception: object reference not set instance of object.] microsoft.office.server.webcontrols.metadatanavtree.onunload(eventargs e) +40 system.web.ui.control.unloadrecursive(boolean dispose) +153 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.control.unloadrecursive(boolean dispose) +306 system.web.ui.page.unloadrecursive(boolean dispose) +23 system.web.ui.page.processrequestcleanup() +54 system.web.ui.page.processrequest(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint) +11045194 system.web.ui.page.processrequest() +91 system.web.ui.page.processrequest(httpcontext context) +240 asp.form_aspx__331913002.processrequest(httpcontext context) in c:\windows\microsoft.net\framework64\v2.0.50727\temporary asp.net files\root\ccd70a06\451bebbc\app_web_form.aspx_-331913002.nurxfpml.0.cs:0 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +599 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +171

4: while if access items on no entry work flow (i.e. when didnt start work flow work flow settings) works fine.

the above mentioned issue not object model approach. works fine. think issue linq

please rid of issue. cant switch linq.

i had same problem, , did:

  1. generate code using spmetal (with or without workflow attached: not matter)

  2. edit generated code change type of field represents workflow status column list, object. in case, changed code looks like:

[system.runtime.serialization.datamemberattribute()] private object _designcompany_setcompanyandfullname;

    [microsoft.sharepoint.linq.columnattribute(name = "setcompa", storage = "_designcompany_setcompanyandfullname", readonly = true, fieldtype = "workflowstatus")]     public system.nullable<int> designcompany_setcompanyandfullname     {                 {             return null; //removed code - may unnecessary         }         set         {             //removed code - may unnecessary         }     } 
  1. compile , deploy.

the error 'specified cast..' should not occur anymore.

the reason (i believe) spmetal has bug , generates system.nullable type fields in generated code represent workflow status columns. checked out code microsoft.sharepoint.linq.dll in reflector, find uses dynamically generated method set field value directly , before setting field tries cast value object whatever field type is.

msdn specifies type mapping 'workflowstatus' type in sharepoint 'object' in .net : http://msdn.microsoft.com/en-us/library/ee536245.aspx

now, atleast don't error anymore.

  • krishna

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -