Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1745
UnauthorizedAccessException on Load()
posted

One of our largest customers is upgrading to Windows7 and has reported that they now get a System.UnauthorizedAccessException when our application first loads. (No problem on WinXP)

The problem occurs at the following line:
   Infragistics.Win.AppStyling.StyleManager.Load(fs)
(where 'fs' is a FileStream)

The file exists under the 'Program Files' branch, so it will be ReadOnly for a standard user.

Does the Load() function attempt to open this file for Write?
If so, how do I tell it NOT to do that.
If not, what else might cause an UnauthorizedAccess exception?

Parents
  • 48586
    Verified Answer
    posted

    Hello ,

     

    UnauthorizedAccessException is thrown when the operating system denies access because of an I/O error or a specific type of security error. So if you use Load method with string fileName parameter then StyleManager will execute the following code:

     

    Stream stream = (Stream) File.OpenRead(fileName))

     

    If you pass a stream as a parameter of the Load method then StyleManager will use the stream directly to read the isl file. So I do not think that StyleManager could cause this issue. However you could try to create an embedded Application Manifest with Your Application, this will allow non-manifested or unsigned code to run with a full administrative access token. How to do this you could find at the following link:

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

     

    Other approach which you could try is to move your isl file to be stored in one of the following folder:

     

    ·        CSIDL_PROFILE

    ·        CSIDL_COMMON_APPDATA

     When running under a managed desktop, an application only has write permission to the following folders and their children. For more information please review the following link:

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

     

    Please let me know if you have any further questions.

Reply Children