wierd exception Access to the path denied


M

mmmobasher

hi,I get some marvelous error from my c# program again & again
:roll: , i guess it is a security exception error, so i disable
security with caspol -s off, give it full trust, copy it to hard
drive, copy it to cd drive, sign it with public/private key, in all
these cases i got the same exception, i use framework 1.1.4322. and
just want to read the file, not write to it, also i am admin of my
computer! and it is in the same directory. why i got this error?
below you can see the exception text.
access to the path "g:\saving document6.cad" is denied
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.UnauthorizedAccessException: Access to the path "G:\saving
document6.cad" 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, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at wordtraining.main.lessonup()
at wordtraining.main.lbxLesson_DoubleClick(Object sender, EventArgs
e)
at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&
m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
wordtraining
Assembly Version: 1.0.1249.40111
Win32 Version: 1.0.1249.40111
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/wordtraining.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Management
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.management/1.0.5000.0__b03f5f7f11d50a3a/system.management.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxMP3PLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/AxMP3PLib.DLL
----------------------------------------
MP3PLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/MP3PLib.DLL
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
Ad

Advertisements

N

Nick Malik [Microsoft]

WAG: have you checked to see if the file is already open, from another file
handle in your application or a file handle in another application?

Also, this deep in the app... why is there no try-catch block?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
mmmobasher said:
hi,I get some marvelous error from my c# program again & again
:roll: , i guess it is a security exception error, so i disable
security with caspol -s off, give it full trust, copy it to hard
drive, copy it to cd drive, sign it with public/private key, in all
these cases i got the same exception, i use framework 1.1.4322. and
just want to read the file, not write to it, also i am admin of my
computer! and it is in the same directory. why i got this error?
below you can see the exception text.
access to the path "g:\saving document6.cad" is denied
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.UnauthorizedAccessException: Access to the path "G:\saving
document6.cad" 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, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at wordtraining.main.lessonup()
at wordtraining.main.lbxLesson_DoubleClick(Object sender, EventArgs
e)
at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&
m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
wordtraining
Assembly Version: 1.0.1249.40111
Win32 Version: 1.0.1249.40111
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/wordtraining.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Management
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.management/1.0.5000.0__b03f5f7f11d50a3a/system.management.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxMP3PLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/AxMP3PLib.DLL
----------------------------------------
MP3PLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Program%20Files/Rayan/wordtraining/MP3PLib.DLL
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/winnt/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
M

mmmobasher

yes, that is a singleton app and one instance is in memory
also i used try/catch block before, it throws security exception.
any oponion?
 
Ad

Advertisements

N

Nick Malik [Microsoft]

I didn't ask if one instance was in memory. I asked if the app was opening
the same file twice.

What else is unusual about your app? The trace that you printed looked a
little different from the traces I've seen. Are you using custom controls?
Are you using Interop? In the App config, do you have identity
impersonate=true set?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
mmmobasher said:
yes, that is a singleton app and one instance is in memory
also i used try/catch block before, it throws security exception.
any oponion?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top