Welcome to Windows Workflow Foundation (WF)
Top Tasks :

WF Community Bloggers

Generic "HasValue" And Policy Activity Gotcha

Recently I noticed this error, Cannot evaluate property "HasValue" because its target object is null. I did not get it at compilation of my workflow project, but running a workflow application. I use generic data types whenever possible, and I use the "HasValue" property as well, so when I started getting this error I was not sure where to start looking. Fortunately, this error means exactly what it says and since I cannot debug to the point where it occurs it probably means it is happening within a WF rule or condition. Normally if you have code that looks like if(NewPerson.IsMarried.HasValue && NewPerson.IsMarried.Value == true) it will process fine, however if you use generic data types regularly like me within policy activities you will come across the same error message like above. Fortunately, the way around this issue is to simply use the null condition so that your policy's business rules look similiar to this... if(NewPerson.IsMarried!=null && NewPerson.IsMarried.Value == true) Read More...
Published Wednesday, June 25, 2008 11:23 PM by Bayer White, Connected Systems MVP - .Net Made Easy With WF
Anonymous comments are disabled

<June 2008>
SuMoTuWeThFrSa
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us