Welcome to Microsoft .NET Framework 3.0 Community (NetFx3)

The .NET Framework is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.

Learn More...

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

Comments

No Comments
Anonymous comments are disabled

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