SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : Microsoft .NET :

Previous DiscussionNext Discussion
 C# to VB.NET

The below code is in C#

this._AdRoot = new DirectoryEntry("LDAP://" + (string)this._AdRootDSE.Properties["defaultNamingContext"].Value);

I am converting it into VB.NEt

Me._AdRoot = New DirectoryEntry("LDAP://" + Convert.ToString(Me._AdRootDSE.Properties("defaultNamingContext").Value))

It should display the details but the output is not as desired. is my conversion from C# to VB.NEt correct? i am getting the correct output with C# code above.

 

 

Started By vini on Apr 2, 2007 at 6:34:45 AM

3 Response(s) | Reply

Earlier Replies | Replies 1 to 3 of 3 | Later Replies
Monte on Apr 2, 2007 at 8:22:04 AM (# 1)

What is the difference(s) in the output?


vini on Apr 2, 2007 at 10:22:51 PM (# 2)

Actually i want to display the all the organisational units that are available in our firm by connecting to AD.

This is the code that is used in c# for that:

lvwColumnSorter = new ListViewColumnSorter();

this.listView_ad.ListViewItemSorter = lvwColumnSorter;

try

{

this._AdRootDSE = new DirectoryEntry("LDAP://rootDSE");

this._AdRoot = new DirectoryEntry("LDAP://" + (string)this._AdRootDSE.Properties["defaultNamingContext"].Value);

/*

foreach(string property in this._AdRoot.Properties.PropertyNames)

{

MessageBox.Show(property + " = " + this._AdRoot.Properties[property].Value);

}*/

TreeNode root = new TreeNode((string)this._AdRootDSE.Properties["defaultNamingContext"].Value,(int)AdImages.AdRoot,(int)AdImages.AdRoot);

root.Tag = this._AdRoot;

this.treeView_ad.Nodes.Clear();

this.treeView_ad.Nodes.Add(root);

}

catch

{

throw new Exception("Error connecting to AD");

}

}

i have converted to vb.net as follows:

lvwColumnSorter = New ListViewColumnSorter

Me.listview_ad.ListViewItemSorter = lvwColumnSorter

Try

Me._AdRootDSE = New DirectoryEntry("LDAP://rootDSE")

Me._AdRoot = New DirectoryEntry("LDAP://" + Convert.ToString(Me._AdRootDSE.Properties("defaultNamingContext").Value))

'for each(string property in this._AdRoot.Properties.PropertyNames)

'{

'MessageBox.Show(property + " = " + this._AdRoot.Properties[property].Value);

'}*/

Dim root As TreeNode

'root = New TreeNode(CType(Me._AdRootDSE.Properties("defaultNamingContext").Value, String), CType(AdImages.AdRoot, Integer), CType(AdImages.AdRoot, Integer))

root = New TreeNode(Convert.ToString(Me._AdRootDSE.Properties("defaultNamingContext").Value), Convert.ToInt32(AdImages.AdRoot), Convert.ToInt32(AdImages.AdRoot))

root.Tag = Me._AdRoot

Me.treeview_ad.Nodes.Clear()

Me.treeview_ad.Nodes.Add(root)

MsgBox("connection established")

Catch

Throw New Exception("Error connecting to AD")

End Try

I have declared the ListViewColumnSorter in Class. When i run it produces the result in C#(conection to the AD is established and all the units are also fetched) but in VB.NEt produces a runtime error "Object reference not set to an object". when i comment the first line "lvwColumnSorter = New ListViewColumnSorter" the connection to the AD is established but nothing is retrived from it :-(


Monte on Apr 3, 2007 at 10:04:08 AM (# 3)

What Imports/using declarations do you have?


Earlier Replies | Replies 1 to 3 of 3 | Later Replies

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.