System.DirectoryServices for VS2010

I am trying to retrieve user info  using/import System.DirectoryServices;
I tried writing code in both VB and C# but got the same results.  When I place the code below in VS2008 and add the DirectoryServices reference, all works fine (plus I see the web config with the assembly reference.   When I try the code in vs2010 it seems to hang on the search FindOne().  I also do NOT see a reference in the web.config.  But I am new to VS2010 so I am not sure about this…..

Could this also be IIS related?  I am running this IIS 5.1….
<add assembly="System.DirectoryServices, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

            Dim search As New DirectorySearcher()
            search.Filter = [String].Format("(SAMAccountName={0})", "user")
            Dim result As SearchResult = search.FindOne()

            If result Is Nothing Then
                Return False
                Return True
            End If
        Catch generatedExceptionName As Exception
            Return False
        End Try
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


just checkout in the project of VS2010, which framework you considered as the target framework.

It may happen that you selected 4.0 which might not have your req code..

Just a guess!

Hope this helps!
Varun Shringarpure

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jsegAuthor Commented:
Thanks.... I was missing  code in web.config

            <compilation debug="true" targetFramework="4.0">
                        <add assembly="System.DirectoryServices, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.