Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
GeneralRe: Porting to C# Pin
Kant28-Feb-04 18:53
Kant28-Feb-04 18:53 
GeneralRe: Porting to C# Pin
Giles29-Feb-04 0:15
Giles29-Feb-04 0:15 
GeneralResizing form background image Pin
Flack27-Feb-04 9:10
Flack27-Feb-04 9:10 
GeneralRe: Resizing form background image Pin
Heath Stewart27-Feb-04 9:59
protectorHeath Stewart27-Feb-04 9:59 
QuestionFileIOPermission also takes away UIPermission? Pin
Nathan Blomquist27-Feb-04 8:37
Nathan Blomquist27-Feb-04 8:37 
AnswerRe: FileIOPermission also takes away UIPermission? Pin
Heath Stewart27-Feb-04 9:38
protectorHeath Stewart27-Feb-04 9:38 
GeneralRe: FileIOPermission also takes away UIPermission? Pin
Nathan Blomquist27-Feb-04 11:21
Nathan Blomquist27-Feb-04 11:21 
GeneralRe: FileIOPermission also takes away UIPermission? Pin
Heath Stewart28-Feb-04 3:16
protectorHeath Stewart28-Feb-04 3:16 
Typically, it's not your code's responsibility. That's what permissions sets that code groups use are for.

I don't see why you're trying to do this like you are. If a plugin calls your method, your method was written by "you" (possibly an org.) so you ultimately control what goes on in there. If you don't use files or sockets, how is a plugin supposed to change that?

Now, if you wanted to make sure that your application had certain permissions but plugins were more restricted, you should consider using a code group based on the strong name of your assembl(y|ies). With real-world applications, you should always sign your assemblies for added benefit, like the ability to be installed into the GAC, to be used by other strong-name assemblies, etc. Use the AssemblyKeyNameAttribute or the AssemblyKeyFileAttribute with a file generated by "sn.exe -k KeyFile.snk", which generates a key pair. Use this for all of your assemblies (putting it in a container with "sn.exe -i MyContainerName KeyFile.snk" and using the AssemblyKeyNameAttribute is often easier with large projects).

If you call one of your plugin methods as you do above, you have a number of things to consider. First, do you even trust the plugin? Perhaps checking the public key token and making sure it's the same as yours or another trusted source would be a good idea. If you want anyone to be able to extend your application, then you're on the right track. Create an instance of the permission(s) and call Deny on the instance. This also means that if callers higher in the stack are trying to access a resource, they won't be able to but a SecurityException will be thrown by callees lower in the stack when a Demand for that permission occurs.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: FileIOPermission also takes away UIPermission? Pin
Nathan Blomquist28-Feb-04 5:11
Nathan Blomquist28-Feb-04 5:11 
GeneralRe: FileIOPermission also takes away UIPermission? Pin
Heath Stewart28-Feb-04 5:25
protectorHeath Stewart28-Feb-04 5:25 
GeneralRe: FileIOPermission also takes away UIPermission? Pin
Nathan Blomquist28-Feb-04 6:34
Nathan Blomquist28-Feb-04 6:34 
GeneralUsercontrol as a container Pin
meago27-Feb-04 8:28
meago27-Feb-04 8:28 
GeneralRe: Usercontrol as a container Pin
Roger Alsing27-Feb-04 9:19
Roger Alsing27-Feb-04 9:19 
GeneralRe: Usercontrol as a container Pin
meago1-Mar-04 12:44
meago1-Mar-04 12:44 
GeneralGet wmv file information Pin
Matt Newman27-Feb-04 8:22
Matt Newman27-Feb-04 8:22 
GeneralRe: Get wmv file information Pin
Heath Stewart27-Feb-04 9:30
protectorHeath Stewart27-Feb-04 9:30 
GeneralCheckbox in Datagrid - check in one click Pin
Ruchi Gupta27-Feb-04 6:35
Ruchi Gupta27-Feb-04 6:35 
GeneralRe: Checkbox in Datagrid - check in one click Pin
Heath Stewart27-Feb-04 8:31
protectorHeath Stewart27-Feb-04 8:31 
Questioncolored lines in console?? Pin
oOomen27-Feb-04 6:32
oOomen27-Feb-04 6:32 
AnswerRe: colored lines in console?? Pin
Heath Stewart27-Feb-04 6:36
protectorHeath Stewart27-Feb-04 6:36 
GeneralRe: colored lines in console?? Pin
Uwe Keim27-Feb-04 7:40
sitebuilderUwe Keim27-Feb-04 7:40 
GeneralVisual Studio Setup and Framework version Pin
Shahin7727-Feb-04 6:17
Shahin7727-Feb-04 6:17 
GeneralRe: Visual Studio Setup and Framework version Pin
Heath Stewart27-Feb-04 6:34
protectorHeath Stewart27-Feb-04 6:34 
GeneralDisplay text in User Control of Child Form Pin
robeneal27-Feb-04 5:28
robeneal27-Feb-04 5:28 
GeneralRe: Display text in User Control of Child Form Pin
Heath Stewart27-Feb-04 5:48
protectorHeath Stewart27-Feb-04 5:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.