Click here to Skip to main content
16,022,536 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am trying to access server state property of the IIS from my asp.net application.But while doing so it is giving following error:

"Attempted to read or write protected memory. Thisoften is an indication that other memory is corrupted ". I tried to search about it but didn't find anything helpful.can anybody help .

Thanx
Posted
Updated 27-May-12 20:27pm
v2
Comments
db7uk 28-May-12 5:22am    
Could you provide any code snippets to what you are doing?
sanketdeshmukh1989 30-May-12 1:57am    
Hello,
I am using below code to check if service is active or not (in that I am accesing server state property ).And if it returns true,I am continuing with sharepoint user creation.

public bool StatusCheck(int siteIndex) {
try {
string ChildPath = "IIS://localhost/w3svc/" + siteIndex.ToString() ;
DirectoryEntry ChildObj = new DirectoryEntry(ChildPath);

int status = (Int32) ChildObj.Properties["ServerState"].Value;
if (status ==2 || status ==1 )
return true ;

if (status ==4 )
return false;

return false;
}
catch(Exception e) {
throw e;
}
}
Sandeep Mewara 28-May-12 5:26am    
Too less an info to comment. Check Windows event viewer, log files to get more info to troubleshoot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900