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?
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.
Thanks for the very complete response.
I didn't think you would be opening it for Read/Write but I just wanted to be sure.
We have many other customers who are using the product without problems so it looks like they may have set up some unusual security rules and simply dont know (or are not admitting it to us)
I wanted to keep the isl files in the same directory as the executable in order to ensure that [standard]users dont start playing around with the files and then reporting problems when they mess them up.
Thanks.Mike