DateTime issues with 4.0 Framework

Jun 29, 2011 at 10:25 PM

Just wondering if anyone has tried to upgrade this project and use it with the 4.0 framework?

I am using this project to wrap my AD, and calling it using a WCF service. It works beautifully in the 4.0 framework, except it seems to have issues bringing back values that are DateTime data types. All other data types seem to work without issues.

My code is simple:

    Dim ROOT As New System.DirectoryServices.DirectoryEntry("LDAP://xxxxx", "xxxxx", "xxxxx")
    Dim users As New DirectorySource(Of ADLinq.User)(ROOT, SearchScope.Subtree)
    Dim res = From usr In users Where usr.Name.StartsWith(searchcriteria)
    Dim dt As DataTable = HelperFunctions.GetBlankTable(GetType(ADLinq.User))
    Dim dr As DataRow
    For Each u In res
       dr = dt.NewRow()
       HelperFunctions.AddRow(dr, u)
       dt.Rows.Add(dr)
    Next
    Dim ds As New DataSet()
    ds.Tables.Add(dt)
    Return ds

The issue occurs in the class DirectorySource.cs, in the function AssignResultProperty. For a data type of DateTime (In my case PasswordLastChanged) when it attempts to get the PropertyInfo from the helper object, the variable 'p' is null, and it crashes on a nullreferenceexception.

The line it crashes on is line 496 of DirectorySource.cs. p is null so there for it crashes.

All other datatypes, it works perfectly, except for DateTime.

Interestingly enough, when I create an Identical service using the 3.5 framework, these issues do not seem to occur. Which tends to lean me towards one of the two references that have changed being the culprit. System.DirectoryServices, or System.Data, however I am not sure.

Was just wondering if anyone has also discovered this issue, or am I totally alone on this one? And if you have figured it out, how did you do so?

Thanks in Advance,

Jason Schatz