473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

System.UnauthorizedAccessException on deserialization

This is also posted in the security newsgroup. Sorry for cross-posting, but
I'm desperate.

I have a Winforms application in VB.NET with a SQL Server (MSDE) backend. In
the root application directory I have an XML file, LicXML.XML which holds
licensing info for the app.

On one group of machines where the users have restricted privileges, the
deserialization of this file trips an error as follows (excuse mispellings
from my client):

My Client Writes:

An error box with a "5" in the left end of the blue top bar appears,
"System.UnauthorizedAccessException: Access to the path
"C:\QMMC\LicXML.xml is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, Fileshare share, Int32 bufferSize, Boolean useAsync,
String msgPath, Boolian bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at QMMC2.modQMMC.DeserializeLicXML()

If my client logs in as Administrator he doesn't get this message and all
works fine.
Can some one help me here. I have shipped this app to hundreds of people
successfully, and this is the first case for this error.
Operating system is XP (Pro, I think) on new machines with Celeron
Processors.

Thanks in advance
Burton Roberts
Nov 11 '05 #1
5 5439
This app is locally installed. NOT running on the web. The code fot
DeserializeLicXML is as follows:
Public Function DeserializeLicXML() As cLicXML
Dim moLicXML As cLicXML
Try
Dim fi As FileInfo = New FileInfo(GetLicXMLFileName)
Dim sz As XmlSerializer
Dim tr As XmlTextReader
Dim fs As FileStream
If fi.Exists Then
fs = New FileStream(GetLicXMLFileName, FileMode.Open)
sz = New XmlSerializer(GetType(cLicXML))
tr = New XmlTextReader(fs)
moLicXML = CType(sz.Deserialize(tr), cLicXML)
fs.Close()
Else
moLicXML = New cLicXML(iPlusDays:=-1)
moLicXML.SerializeMe()
End If
Return moLicXML
Catch ex As Exception
MessageBox.Show(ex.ToString, Err.Number)
End Try
End Function

Public Function GetLicXMLFileName() As String
Dim sb As StringBuilder = New StringBuilder(Application.StartupPath)
sb.Append("\LicXML.xml")
Return sb.ToString
End Function

Thanks in advance
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:uC**************@TK2MSFTNGP12.phx.gbl...
How are you deserializing and how is the app running? Is it locally
installed or running via the web ?

Christoph

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:#t**************@tk2msftngp13.phx.gbl...
This is also posted in the security newsgroup. Sorry for cross-posting, but
I'm desperate.

I have a Winforms application in VB.NET with a SQL Server (MSDE) backend. In
the root application directory I have an XML file, LicXML.XML which

holds licensing info for the app.

On one group of machines where the users have restricted privileges, the
deserialization of this file trips an error as follows (excuse mispellings from my client):

My Client Writes:

An error box with a "5" in the left end of the blue top bar appears,
"System.UnauthorizedAccessException: Access to the path
"C:\QMMC\LicXML.xml is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, Fileshare share, Int32 bufferSize, Boolean useAsync,
String msgPath, Boolian bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at QMMC2.modQMMC.DeserializeLicXML()

If my client logs in as Administrator he doesn't get this message and all works fine.
Can some one help me here. I have shipped this app to hundreds of people
successfully, and this is the first case for this error.
Operating system is XP (Pro, I think) on new machines with Celeron
Processors.

Thanks in advance
Burton Roberts


Nov 11 '05 #2
Burton,

When you look at the stack trace in the exception you see that the
XmlSerializer has nothing to so with this. The exception is already
happening in the constructor of the FileStream.

I have a few more questions maybe we can figure it out.

* Are you sure the environment where you application is running in actually
grants users of .NET applications privileges to read from the C drive? Can
you ask the client to open the .NET Framework 1.x Configuration app, right
click Runtime Security Police, select Evaluate Assembly and check what
Permission Sets active for the app and the details of the File IO
permissions in particular?

* Is there a chance that another user or another application already have
that file open and locked it?

* Since it doesn't appear that you actually need the file for writing, can
you open it with FileAccess.Read?

* Does SerializeMe() work when the file is not already present?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
This app is locally installed. NOT running on the web. The code fot
DeserializeLicXML is as follows:
Public Function DeserializeLicXML() As cLicXML
Dim moLicXML As cLicXML
Try
Dim fi As FileInfo = New FileInfo(GetLicXMLFileName)
Dim sz As XmlSerializer
Dim tr As XmlTextReader
Dim fs As FileStream
If fi.Exists Then
fs = New FileStream(GetLicXMLFileName, FileMode.Open)
sz = New XmlSerializer(GetType(cLicXML))
tr = New XmlTextReader(fs)
moLicXML = CType(sz.Deserialize(tr), cLicXML)
fs.Close()
Else
moLicXML = New cLicXML(iPlusDays:=-1)
moLicXML.SerializeMe()
End If
Return moLicXML
Catch ex As Exception
MessageBox.Show(ex.ToString, Err.Number)
End Try
End Function

Public Function GetLicXMLFileName() As String
Dim sb As StringBuilder = New StringBuilder(Application.StartupPath)
sb.Append("\LicXML.xml")
Return sb.ToString
End Function

Thanks in advance
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:uC**************@TK2MSFTNGP12.phx.gbl...
How are you deserializing and how is the app running? Is it locally
installed or running via the web ?

Christoph

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:#t**************@tk2msftngp13.phx.gbl...
This is also posted in the security newsgroup. Sorry for cross-posting,
but
I'm desperate.

I have a Winforms application in VB.NET with a SQL Server (MSDE) backend.
In
the root application directory I have an XML file, LicXML.XML which

holds licensing info for the app.

On one group of machines where the users have restricted privileges,
the deserialization of this file trips an error as follows (excuse

mispellings from my client):

My Client Writes:

An error box with a "5" in the left end of the blue top bar appears,
"System.UnauthorizedAccessException: Access to the path
"C:\QMMC\LicXML.xml is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, Fileshare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolian bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at QMMC2.modQMMC.DeserializeLicXML()

If my client logs in as Administrator he doesn't get this message and all works fine.
Can some one help me here. I have shipped this app to hundreds of people successfully, and this is the first case for this error.
Operating system is XP (Pro, I think) on new machines with Celeron
Processors.

Thanks in advance
Burton Roberts



Nov 11 '05 #3
I had my user open the Configuration App and check runtime security policy
for the executable file.

For All levels, permissions Granted to this assembly = Unrestricted.

I didn't konw how to check for the File IO permissions in particular.
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Burton,

When you look at the stack trace in the exception you see that the
XmlSerializer has nothing to so with this. The exception is already
happening in the constructor of the FileStream.

I have a few more questions maybe we can figure it out.

* Are you sure the environment where you application is running in actually grants users of .NET applications privileges to read from the C drive? Can
you ask the client to open the .NET Framework 1.x Configuration app, right
click Runtime Security Police, select Evaluate Assembly and check what
Permission Sets active for the app and the details of the File IO
permissions in particular?

* Is there a chance that another user or another application already have
that file open and locked it?

* Since it doesn't appear that you actually need the file for writing, can
you open it with FileAccess.Read?

* Does SerializeMe() work when the file is not already present?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
This app is locally installed. NOT running on the web. The code fot
DeserializeLicXML is as follows:
Public Function DeserializeLicXML() As cLicXML
Dim moLicXML As cLicXML
Try
Dim fi As FileInfo = New FileInfo(GetLicXMLFileName)
Dim sz As XmlSerializer
Dim tr As XmlTextReader
Dim fs As FileStream
If fi.Exists Then
fs = New FileStream(GetLicXMLFileName, FileMode.Open)
sz = New XmlSerializer(GetType(cLicXML))
tr = New XmlTextReader(fs)
moLicXML = CType(sz.Deserialize(tr), cLicXML)
fs.Close()
Else
moLicXML = New cLicXML(iPlusDays:=-1)
moLicXML.SerializeMe()
End If
Return moLicXML
Catch ex As Exception
MessageBox.Show(ex.ToString, Err.Number)
End Try
End Function

Public Function GetLicXMLFileName() As String
Dim sb As StringBuilder = New StringBuilder(Application.StartupPath)
sb.Append("\LicXML.xml")
Return sb.ToString
End Function

Thanks in advance
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:uC**************@TK2MSFTNGP12.phx.gbl...
How are you deserializing and how is the app running? Is it locally
installed or running via the web ?

Christoph

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:#t**************@tk2msftngp13.phx.gbl...
> This is also posted in the security newsgroup. Sorry for cross-posting, but
> I'm desperate.
>
> I have a Winforms application in VB.NET with a SQL Server (MSDE)

backend.
In
> the root application directory I have an XML file, LicXML.XML which

holds
> licensing info for the app.
>
> On one group of machines where the users have restricted privileges, the > deserialization of this file trips an error as follows (excuse

mispellings
> from my client):
>
> My Client Writes:
>
> An error box with a "5" in the left end of the blue top bar appears,
> "System.UnauthorizedAccessException: Access to the path
> "C:\QMMC\LicXML.xml is denied.
> at System.IO.__Error.WinIOError(Int32 errorCode, String str)
> at System.IO.FileStream..ctor(String path, FileMode mode,
> FileAccess access, Fileshare share, Int32 bufferSize, Boolean useAsync, > String msgPath, Boolian bFromProxy)
> at System.IO.FileStream..ctor(String path, FileMode mode)
> at QMMC2.modQMMC.DeserializeLicXML()
>
> If my client logs in as Administrator he doesn't get this message
and all
> works fine.
> Can some one help me here. I have shipped this app to hundreds of

people > successfully, and this is the first case for this error.
> Operating system is XP (Pro, I think) on new machines with Celeron
> Processors.
>
> Thanks in advance
> Burton Roberts
>
>



Nov 11 '05 #4
You can select "View code groups that grant permissions to the assembly".

then go to that code group and check the permissions included in that code
groupt clicking, selecting properties and then going to the "Permission Set"
tab. Locate "File IO" and see what's going on. It sounds pretty unlikely
that this is it because you've said the assembly has unrestricted
permissions.

VERY STRANGE...
Christoph

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
I had my user open the Configuration App and check runtime security policy
for the executable file.

For All levels, permissions Granted to this assembly = Unrestricted.

I didn't konw how to check for the File IO permissions in particular.
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Burton,

When you look at the stack trace in the exception you see that the
XmlSerializer has nothing to so with this. The exception is already
happening in the constructor of the FileStream.

I have a few more questions maybe we can figure it out.

* Are you sure the environment where you application is running in actually
grants users of .NET applications privileges to read from the C drive? Can
you ask the client to open the .NET Framework 1.x Configuration app, right click Runtime Security Police, select Evaluate Assembly and check what
Permission Sets active for the app and the details of the File IO
permissions in particular?

* Is there a chance that another user or another application already have that file open and locked it?

* Since it doesn't appear that you actually need the file for writing, can you open it with FileAccess.Read?

* Does SerializeMe() work when the file is not already present?

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

"Burton Roberts" <bh*******@adelphia.net> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
This app is locally installed. NOT running on the web. The code fot
DeserializeLicXML is as follows:
Public Function DeserializeLicXML() As cLicXML
Dim moLicXML As cLicXML
Try
Dim fi As FileInfo = New FileInfo(GetLicXMLFileName)
Dim sz As XmlSerializer
Dim tr As XmlTextReader
Dim fs As FileStream
If fi.Exists Then
fs = New FileStream(GetLicXMLFileName, FileMode.Open)
sz = New XmlSerializer(GetType(cLicXML))
tr = New XmlTextReader(fs)
moLicXML = CType(sz.Deserialize(tr), cLicXML)
fs.Close()
Else
moLicXML = New cLicXML(iPlusDays:=-1)
moLicXML.SerializeMe()
End If
Return moLicXML
Catch ex As Exception
MessageBox.Show(ex.ToString, Err.Number)
End Try
End Function

Public Function GetLicXMLFileName() As String
Dim sb As StringBuilder = New StringBuilder(Application.StartupPath) sb.Append("\LicXML.xml")
Return sb.ToString
End Function

Thanks in advance
Burton Roberts

"Christoph Schittko [MVP]" <ch********************@austin.rr.com> wrote in message news:uC**************@TK2MSFTNGP12.phx.gbl...
> How are you deserializing and how is the app running? Is it locally
> installed or running via the web ?
>
> Christoph
>
> "Burton Roberts" <bh*******@adelphia.net> wrote in message
> news:#t**************@tk2msftngp13.phx.gbl...
> > This is also posted in the security newsgroup. Sorry for

cross-posting,
> but
> > I'm desperate.
> >
> > I have a Winforms application in VB.NET with a SQL Server (MSDE)
backend.
> In
> > the root application directory I have an XML file, LicXML.XML
which holds
> > licensing info for the app.
> >
> > On one group of machines where the users have restricted privileges,
the
> > deserialization of this file trips an error as follows (excuse
mispellings
> > from my client):
> >
> > My Client Writes:
> >
> > An error box with a "5" in the left end of the blue top bar

appears, > > "System.UnauthorizedAccessException: Access to the path
> > "C:\QMMC\LicXML.xml is denied.
> > at System.IO.__Error.WinIOError(Int32 errorCode, String str) > > at System.IO.FileStream..ctor(String path, FileMode mode,
> > FileAccess access, Fileshare share, Int32 bufferSize, Boolean

useAsync,
> > String msgPath, Boolian bFromProxy)
> > at System.IO.FileStream..ctor(String path, FileMode mode)
> > at QMMC2.modQMMC.DeserializeLicXML()
> >
> > If my client logs in as Administrator he doesn't get this message

and all
> > works fine.
> > Can some one help me here. I have shipped this app to hundreds of

people
> > successfully, and this is the first case for this error.
> > Operating system is XP (Pro, I think) on new machines with Celeron
> > Processors.
> >
> > Thanks in advance
> > Burton Roberts
> >
> >
>
>



Nov 11 '05 #5
> I haven't used, nor was I aware of, the .NET Configuration App. When I
try
to open it on my development machine, it doesn't open. It does open on a my test client machine, however, so I can still walk my client through it. The other application, .NET Framework Wizards does open on both machines. Is
there anything noteworthy there?
No, the wizards are just a simplified UI to the some often used
functionality of the configuration tool.
SerializeMe() should work when when the file is not already present. You'll notice we test for the file's existence, if its not there we create a new
serializable class and serialize it making a license file that is

"expired".

but deserializing should also work ;)

I am asking to find out if your app has write permissions to the location of
you xml file.

Also, have you had a chance to deserialize the with a read-only stream ...

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MVP XML
Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Krazitchek | last post by:
Hi, i check all directories on a disk but an error occurs when i try to enter in the "System Volume Information" directory. Is there a way to "jump" this directory without to check the name of...
0
by: Efi | last post by:
Hi, We have a simple 3 tier application which its core application is VC++ 6.0 ATL COM running as a server application in the COM+. An asp pipe is in charge of handling the requests and passes it...
7
by: Peter Afonin | last post by:
Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\") Dim files() As FileInfo = dir.GetFiles("*.eps")...
0
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is...
0
by: nime | last post by:
I've got a problem. I cannot debug my app. which one contains WebBrowser control. I found a resolution but it's for an ASP related problem. I couldn't find a correct "user" to give permisson then...
5
by: Max | last post by:
hi i have file browser control to select any file and a button to upload file on my web page now when i select any file. now on click of upload button i have check that file exist or no if...
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
3
by: BLUE | last post by:
I've created a folder named TestDir in my wwwroot and I've created the associated virtual application from IIS management snap-in. I've given full control to TestDir to: IUSR, ASPNET, Network...
1
by: nygiantswin2005 | last post by:
Hi I am trying to resolve this bug that I have in this application. The code is below. It will generate this Exception System.UnauthorizedAccessException: Access to the path is denied. at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.