Exception when using System.Management class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthi84
    Contributor
    • Dec 2006
    • 270

    Exception when using System.Management class

    Hi Experts,

    i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and install it, the codes are copied to the virtual directory under Inetpub. when i try to edit the web.config file it throws an exception access is denied to web.config file.
    but the same project works fine if i copy the file to some other location and manually configure them to the IIS.
    so i have modified my code to add the ASPNET user to the virtual directory with full rights using System.Manageme nt class. this also works fine if the code is outside the Inetpub folder. if i create an installer for this this throws the below error.
    "System.Managem ent.ManagementE xception: Access denied at System.Manageme nt.ManagementEx ception.ThrowWi thExtendedInfo( ManagementStatu s errorCode) at System.Manageme nt.ManagementSc ope.InitializeG uts(Object o) at System.Manageme nt.ManagementSc ope.Initialize( ) at System.Manageme nt.ManagementOb jectSearcher.In itialize() at System.Manageme nt.ManagementOb jectSearcher.Ge t() at DataBaseConnect ions.setRights( ) in c:\Inetpub\wwwr oot\AurasavGUI\ DataBaseConnect ions.aspx.cs:li ne 50 "

    requesting you for some ideas to overcome this issue.

    Thanks and regards
    karthi
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    what you have done is correct.. i dont understand why you are getting system.manageme nt error ...can you throw some light on that ?

    Comment

    • karthi84
      Contributor
      • Dec 2006
      • 270

      #3
      Hi Deep Blue,

      I hope this could be the cause. the system is not allowing the ASPNET user to alter the permission of its folders. any way i have achived my requirement using a third party installer.

      Buit still doing some research on how to solve this issue. If i found a solution for this i will soon post here.

      Thanks for the help.

      Thanks & Regards
      Karthi

      Comment

      Working...