Newbe: C# 2003 PermissionSet question


E

Executor

I have created a user control which I would like to use in other
projects.
When I try to create an instance on a form in an other project I get an
error message.

This is the AssemblyInfo.cs of my control:

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]


[assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("..\\..\\MyControl.snk")]
[assembly: AssemblyKeyName("")]

[assembly: PermissionSet(SecurityAction.RequestOptional, Unrestricted =
false)]

[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]


This is the text of the error message:

An exception occurred while trying to create an instance of
MyControl.MyControl
The exception was "Request for the permission of type
System.Security.Permissions.SecurityPermission, mscorlob,
Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089
failed



I think the problem arises from my PermissionSet(...,...).

Has anyone a suggestion which PermissionSet I should use to solve this?

Thanks in advance.
 
Ad

Advertisements

B

Bala

I am not sure about this, but shouldn't you at first request a
permission before instantiating this (custom) control?

See:
..NET Framework Developer's Guide --> Requesting Permissions
 
C

chanmm

You don't need PermissionSet for control. I got a sample for you but 111kb
after zip so can't send over.

chanmm
 
Ad

Advertisements

E

Executor

I figured it out:

The permission line shuld read:

[Assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum,
Execution =True, Unrestricted =False)]

Thanks to all who tried to inform me.
 

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