Microsoft KB Archive/820637

= You receive a &quot;System.Security.SecurityException&quot; message when the LinkLabel property runs in a partially-trusted context =

Article ID: 820637

Article Last Modified on 1/27/2006

-

APPLIES TO


 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Express Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-



SYMPTOMS
If you use a LinkLabel control on a localized Windows Form, the application raises the following exception while it tries to deserialize the LinkArea property during run time:

An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll.

Additional information: Request for the permission of type System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

Note In Visual Studio 2005, you will receive the following exception:

Never enter personal information or passwords into a window unless you can verify and trust the source of the request. Source: Unknown Site



CAUSE
The application raises the exception because the LinkArea property cannot be deserialized when the property runs in a partially-trusted context.



WORKAROUND
To work around this problem, set the unrestricted property to True, so that the property runs in a fully-trusted context, as follows.

Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 Code Imports System.Security.Permissions   Microsoft Visual C# or Microsoft Visual C# 2005 Code using System.Security.Permissions; [assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name=&quot;Internet&quot;)] [assembly: PermissionSetAttribute(SecurityAction.RequestOptional, Unrestricted=true)]



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
 Create a Windows application by using Visual Basic .NET, Visual Basic 2005, Visual C# 2005, or Visual C# .NET. Drag a LinkLabel control to Form1. Right-click Form1, and then click Properties. In the Properties window, set the Localizable property to True .  Copy the following code, and then paste the code at the top of the AssemblyInfo file, below any IMPORTS statements.

Visual Basic .NET or Visual Basic 2005 Code Imports System.Security.Permissions <Assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name:=&quot;Internet&quot;)> <Assembly: PermissionSetAttribute(SecurityAction.RequestOptional, Unrestricted:=False)> Visual C# .NET or Visual C# 2005 Code using System.Security.Permissions; [assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name=&quot;Internet&quot;)] [assembly: PermissionSetAttribute(SecurityAction.RequestOptional, Unrestricted=false)] </li> On the Debug menu, click Start to run the application.

You receive the error that is mentioned in the &quot;Symptoms&quot; section of this article.</li></ol>

Keywords: kbwindowsforms kbuidesign kbsecurity kbprb kbctrl kbcontrol kbvs2005applies kbvs2005swept KB820637

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.