locked
Corrupted memory exception RRS feed

  • Question

  • Hello,
     
    I am sending  request to create user in sharepoint from my asp.net application. Before that I am trying to access server state property of the IIS  .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.
    Monday, May 28, 2012 7:06 AM

Answers

  • Hi Sanket,

    If still you stuck in the same situation
    Pretty sure then its memory leak issue on the code and execution before the actually calling the StatusCheck function.

    For the same would recommend to use SPDisposeCheck - Tool to detect memory leaks, which detects possible memory leaks in custom SharePoint solutions which do not comply with Microsoft’s best practices

    Also you can refer to the best practices to ensure object disposal and any memeory leak kind of scenario. Article also provide the insight for disposal concepts in sharepoints

    http://msdn.microsoft.com/en-us/library/ee557362.aspx
    http://msdn.microsoft.com/en-us/library/aa973248.aspx

    Hope it helps !!!


    Shailendra Mohan


    Friday, June 8, 2012 8:17 AM

All replies

  • Hi Sanket,

    Would be helpful if you can share the code snippet and exact purpose for using state property while adding users in sharepoint.

    As if you are using SPweb/spsite objects in your asp.net code it would be helpful to know at where exactlly the problem arrives for you.


    Shailendra Mohan


    Monday, May 28, 2012 10:42 AM
  • 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;
                }
            }

    Tuesday, May 29, 2012 6:25 AM
  • Hi Sanket,

    If still you stuck in the same situation
    Pretty sure then its memory leak issue on the code and execution before the actually calling the StatusCheck function.

    For the same would recommend to use SPDisposeCheck - Tool to detect memory leaks, which detects possible memory leaks in custom SharePoint solutions which do not comply with Microsoft’s best practices

    Also you can refer to the best practices to ensure object disposal and any memeory leak kind of scenario. Article also provide the insight for disposal concepts in sharepoints

    http://msdn.microsoft.com/en-us/library/ee557362.aspx
    http://msdn.microsoft.com/en-us/library/aa973248.aspx

    Hope it helps !!!


    Shailendra Mohan


    Friday, June 8, 2012 8:17 AM
  • Thanks Shailendra for introducing me to SP Dispose Check Tool, having similar exception thrown for me too.

    Also suggested msdn links are valuable too.Thanks again.

    Friday, June 8, 2012 10:32 AM