DirectoryEntries.Find Method get Exception from HRESULT: 0x80005008 or NullReferenceException

  • Thread starter Thread starter Marc Scheuner [MVP ADSI]
  • Start date Start date
M

Marc Scheuner [MVP ADSI]

public DirectoryEntry Find(string, string) method get Exception from
HRESULT: 0x80005008
public DirectoryEntry Find(string); method get NullReferenceException

source code :
DirectoryEntry rootfolder = new
DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");

Have you checked at this point to make sure "rootfolder" is not
null???

if(rootfolder != null)
{
DirectoryEntry de = rootfolder.Children.Find("docula5",
"IIsWebVirtualDir");//,rootfolder.SchemaClassName);
}
else
{
MessageBox.Show("Your 'rootfolder' is NULL !!");
}

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
rootfolder is not null.

If I delete the line :
deNewVDir.Invoke("AppCreate",true);
the find method work fine.
 
rootfolder is not null.

And rootfolder.Children? Does it contain any children at all?

Marc
If I delete the line :
deNewVDir.Invoke("AppCreate",true);
the find method work fine.

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
public DirectoryEntry Find(string, string) method get Exception from
HRESULT: 0x80005008
public DirectoryEntry Find(string); method get NullReferenceException

source code :

string strSchema = "IIsWebVirtualDir";
string strRootSubPath = "/W3SVC/1/Root";
DirectoryEntry deRoot= new DirectoryEntry("IIS://localhost" +
strRootSubPath);
try
{

DirectoryEntry deNewVDir =
deRoot.Children.Add("docula5",deRoot.SchemaClassName);
deNewVDir.Properties["Path"].Insert(0,"D:\\temp");
// Create a Application
deNewVDir.Properties["AccessRead"].Add(true);
deNewVDir.Properties["AccessScript"].Add(true);
deNewVDir.Properties["Path"].Add("D:\\temp");
deNewVDir.Properties["AppFriendlyName"].Add("docula5");
deNewVDir.Invoke("AppCreate",true);
// Save Changes
deNewVDir.CommitChanges();
deRoot.CommitChanges();
deNewVDir.Close();
deRoot.Close();


DirectoryEntry rootfolder = new
DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry de = rootfolder.Children.Find("docula5",
"IIsWebVirtualDir");//,rootfolder.SchemaClassName);

win2000 Pro
 
Back
Top