.NET Forum / .NET Framework / Security / February 2006
System.Security.SecurityException was unhandled
|
|
Thread rating:  |
Seok Bee - 15 Feb 2006 11:10 GMT Dear Experts,
I've created a Console application to perform a checking of an Excel file. During development using vb.net in Visual Studio 2005, the application is running fine. I can get my expected result. Then I move the executable files and related *.dll files into a server to schedule for execution. The server is running on Windows 2000 sp4 and installed with .NET Frameword 1.1 and 2.0. When I execute the application I received and error message. The error is as follow shown in the debugger:
System.Security.SecurityException was unhandled Message="System.Security.Permissions.SecurityPermission" Source="SPQAutomation" StackTrace: at SPQAutomation.SPQAutomation.Main()
While, from the Application log in Event Viewver I have the following error:
Event Type: Error Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5000 Date: 15-Feb-06 Time: 6:57:51 PM User: N/A Computer: IT3 Description: EventType clr20r3, P1 spqautomation.exe, P2 1.0.0.0, P3 43f3058e, P4 spqautomation, P5 1.0.0.0, P6 43f3058e, P7 18, P8 1, P9 system.security.security, P10 NIL.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
May I know, what should I do/configure in the server in order for my application to be executed?
Many thanks in advance.
Regards, SB
Nicole Calinoiu - 15 Feb 2006 20:37 GMT This is not a server-level issue. Instead, it's caused by the CAS permission grant on the client machine, which will be more restricted when running from a network location than from the local machine. (See http://blogs.msdn.com/shawnfa/archive/2003/06/20/57023.aspx for details.) Given the particular exception description you've posted, my first guess would be that one of your DLLs might contain unverifiable or unsafe code and that the permission that's failing is a SecurityPermission\SkipVerification. Otherwise, a link demand might be the culprit, and you may be able to gather more information about the exception by moving the body of your current Main method into a new method. e.g.:
private static void Main(string[] args) { MainHelper(args); }
private static void MainHelper(string[] args) { // Everything from your original Main method goes here. }
> Dear Experts, > [quoted text clipped - 42 lines] > Regards, > SB Seok Bee - 17 Feb 2006 01:10 GMT I have tried the following and the execution is still failed.
1) Installation of .NET Framework 2.0 SDK 2) Update the policy security level to "Full Trusted" for LocalIntranet_Zone 3) Change the program to the new methos suggested. 4) Recompiled the program and moved the executable file and *.dll files to the server
Server Information: OS : Win2k sp4 Framework installed: 1.1, 2.0
I've tried execute the program remotely over the network and it works on my machine. The platform that I am running is Winxp with .net framework 1.1, 1.1 Hotfix & 2.0. Not sure why the execution still failed when i run directly from the server. The error message is still the same as i got previously. Please advise.
Many thanks in advance.
> This is not a server-level issue. Instead, it's caused by the CAS > permission grant on the client machine, which will be more restricted when [quoted text clipped - 63 lines] > > Regards, > > SB Nicole Calinoiu - 17 Feb 2006 16:11 GMT >I have tried the following and the execution is still failed. > > 1) Installation of .NET Framework 2.0 SDK > 2) Update the policy security level to "Full Trusted" for > LocalIntranet_Zone On the server or the client? In which version of the Framework did you adjust the permission grant to the intranet zone?
> 3) Change the program to the new methos suggested. > 4) Recompiled the program and moved the executable file and *.dll files to [quoted text clipped - 10 lines] > Hotfix & 2.0. Not sure why the execution still failed when i run directly > from the server. The error message is still the same as i got previously. Have you tried granting the assemblies additional CAS permissions in the v. 2.0 Framework on the client machine? Also, could you please provide the full exception details (including call stack listing), as returned by its ToString method?
> Please advise. > [quoted text clipped - 76 lines] >> > Regards, >> > SB Seok Bee - 17 Feb 2006 16:42 GMT I have set the policy security level on both the client and server. Also, the setting was done on both versions 1.1 and 2.0 .NET framework.
> Have you tried granting the assemblies additional CAS permissions in the v. 2.0 > Framework on the client machine? No, I have not done this. May I know where and how to grant the assemblies additional CAS permissions. I will send u the exception message later... as i need to do it in the office....
> >I have tried the following and the execution is still failed. > > [quoted text clipped - 105 lines] > >> > Regards, > >> > SB Craig - 18 Feb 2006 02:31 GMT I was getting the same kind of error through another application.
I did everything you did to no avail.
I then came across another KB article from MS where it said to Assert the permission of the method required.
I was using Oracle so was getting an Oracle permission problem. What I did was... OraclePermission perm = new OraclePermission(Unrestricted); perm.Assert();
Also had a problem with IO so did this FileIOPermission perm = new FileIOPermission(Unrestricted); perm.Assert();
Try and find the sorce of the security permission error, then get the correct permission type for it and assert it unrestricted.
Craig
>I have set the policy security level on both the client and server. Also, >the [quoted text clipped - 130 lines] >> >> > Regards, >> >> > SB Seok Bee - 18 Feb 2006 03:59 GMT From the error message that I could recalled when I did a debug, it stops at the Excel application declaration. So could it be, there is a restriction or permission issue on accessing the the Excel application?
> I was getting the same kind of error through another application. > [quoted text clipped - 151 lines] > >> >> > Regards, > >> >> > SB Nicole Calinoiu - 19 Feb 2006 16:01 GMT This will not work for most scenarios since assertion only works if your assembly actually has the permission in question. If assertion worked for you, I'm guessing that your scenario probably involved either an IE-hosted Windows Forms control or a high privilege executable referencing low privilege DLLs. However, in this case, both the executable and the DLLs are low privilege, so assertion from the executable will not help.
>I was getting the same kind of error through another application. > [quoted text clipped - 158 lines] >>> >> > Regards, >>> >> > SB Seok Bee - 20 Feb 2006 00:18 GMT Hi, the error message that I received from the CLR debugger is as follow:
An unhandled exception of type "system.runtime.interopservices.COMException' occured in <executable filename>
addition information: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
While from the Application Log in the Event Viewer is as folllow:
Event Type: Error Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5000 Date: 20-Feb-06 Time: 8:10:34 AM User: N/A Computer: TEKLANG2 Description: EventType clr20r3, P1 spqautomation.exe, P2 1.0.0.0, P3 43f44487, P4 spqautomation, P5 1.0.0.0, P6 43f44487, P7 19, P8 1, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL. Data: 0000: 63 00 6c 00 72 00 32 00 c.l.r.2. 0008: 30 00 72 00 33 00 2c 00 0.r.3.,. 0010: 20 00 73 00 70 00 71 00 .s.p.q. 0018: 61 00 75 00 74 00 6f 00 a.u.t.o. 0020: 6d 00 61 00 74 00 69 00 m.a.t.i. 0028: 6f 00 6e 00 2e 00 65 00 o.n...e. 0030: 78 00 65 00 2c 00 20 00 x.e.,. . 0038: 31 00 2e 00 30 00 2e 00 1...0... 0040: 30 00 2e 00 30 00 2c 00 0...0.,. 0048: 20 00 34 00 33 00 66 00 .4.3.f. 0050: 34 00 34 00 34 00 38 00 4.4.4.8. 0058: 37 00 2c 00 20 00 73 00 7.,. .s. 0060: 70 00 71 00 61 00 75 00 p.q.a.u. 0068: 74 00 6f 00 6d 00 61 00 t.o.m.a. 0070: 74 00 69 00 6f 00 6e 00 t.i.o.n. 0078: 2c 00 20 00 31 00 2e 00 ,. .1... 0080: 30 00 2e 00 30 00 2e 00 0...0... 0088: 30 00 2c 00 20 00 34 00 0.,. .4. 0090: 33 00 66 00 34 00 34 00 3.f.4.4. 0098: 34 00 38 00 37 00 2c 00 4.8.7.,. 00a0: 20 00 31 00 39 00 2c 00 .1.9.,. 00a8: 20 00 31 00 2c 00 20 00 .1.,. . 00b0: 70 00 73 00 7a 00 71 00 p.s.z.q. 00b8: 6f 00 61 00 64 00 68 00 o.a.d.h. 00c0: 78 00 31 00 75 00 35 00 x.1.u.5. 00c8: 7a 00 61 00 68 00 62 00 z.a.h.b. 00d0: 68 00 6f 00 68 00 67 00 h.o.h.g. 00d8: 68 00 6c 00 64 00 67 00 h.l.d.g. 00e0: 69 00 79 00 34 00 71 00 i.y.4.q. 00e8: 69 00 78 00 68 00 78 00 i.x.h.x. 00f0: 20 00 4e 00 49 00 4c 00 .N.I.L. 00f8: 0d 00 0a 00 ....
A million Thanks to you Nicole, and hope that you could help me on solving this problem. Thanks once more.
Regards, SB
> This will not work for most scenarios since assertion only works if your > assembly actually has the permission in question. If assertion worked for [quoted text clipped - 165 lines] > >>> >> > Regards, > >>> >> > SB Nicole Calinoiu - 20 Feb 2006 13:21 GMT Your original message was about a SecurityException, but this is a COMException. Are you still seeing the SecurityException at all? If not, you have presumably resolved your security issue by granting the necessary CAS permissions on the client machine, and the COM issue is a new problem. In this case, the first thing to check might be whether the COM server that you are attempting to invoke is actually registered on the client machine.
> Hi, the error message that I received from the CLR debugger is as follow: > [quoted text clipped - 246 lines] >> >>> >> > Regards, >> >>> >> > SB Seok Bee - 21 Feb 2006 00:25 GMT Will I be able to find out which is the COM services that is not being installed?
Is it a must that I need to register the COM server to the machine using Regsvr command or can I just move/copy all the dlls created (when I build the solution) to the client machine, which is the server in this case ?
> Your original message was about a SecurityException, but this is a > COMException. Are you still seeing the SecurityException at all? If not, [quoted text clipped - 253 lines] > >> >>> >> > Regards, > >> >>> >> > SB Nicole Calinoiu - 22 Feb 2006 14:03 GMT > Will I be able to find out which is the COM services that is not being > installed? The exception gave you the CLSID. You should be able to look this up in the registry of the machine on which the code is working correctly in order to determine what COM component it represents.
> Is it a must that I need to register the COM server to the machine using > Regsvr command or can I just move/copy all the dlls created (when I build > the > solution) to the client machine, which is the server in this case ? That depends. If your client platforms support it, you may be able to use registration-free COM (see http://msdn.microsoft.com/library/en-us/cpguide/html/cpconregistration-freecomin terop.asp, http://msdn.microsoft.com/library/en-us/cpguide/html/cpconregistration-freecomin terop.asp). Otherwise, you will need to ensure that the COM component(s) are properly registered on each client machine.
>> Your original message was about a SecurityException, but this is a >> COMException. Are you still seeing the SecurityException at all? If [quoted text clipped - 281 lines] >> >> >>> >> > Regards, >> >> >>> >> > SB
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|