473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

StrongNameIdentityPermission Permission

Hi

I am trying to protect a class from being used by anything other than the application for which it was intended with StrongNameIdentityPermission using declarative code access security

In my solution, I have a Windows Forms Project called MainApp which I have signed with a strong name key. I also have a Class Library Project called CallClass, which I have signed with the same key

CallClass contains one class called MyClass which is coded as follows :

[StrongNameIdentityPermission(SecurityAction.LinkDe mand, PublicKey="<public key>", Name="MainApp.exe", Version="1.0.0.0")
public class MyClas

public MyClass(

public static string LogonSucceed(

return "This message indicates the logon process succeeded."

I obtained the public key by running sn -Tp against the .snk file

MainApp has a reference to CallClass, and contains 1 Win Form called MainForm. The Load Event for MainForm is coded as follows :

private void MainForm_Load(object sender, System.EventArgs e

try

MessageBox.Show(MyClass.LogonSucceed())

catch (SecurityException ex

MessageBox.Show("MyClass is unavailable. " + ex.Message)
Application.Exit()

When I run this app in VS.NET 2003, I receive the following error :
Request for the permission of type System.Security.Permissions.StrongNameIdentityPerm ission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=<public key token> failed

Note that the stack trace for the exception and manual tracing indicate that the exception occurs before any code within MainForm_Load is actually run

My understanding is that an exception will occur when you specify a Security Action of Demand in the attribute, because a full stack walk is performed and all callers, all the way back to mscorlib are expected to have been signed with the same strong name key

However, I am using LinkDemand, which should only require the immediate caller to be signed with the key

Note that I have also posted this one to the dotnet.security group. But I thought I'd post it here too just in case

Any help you could provide to solve this problem would be much appreciated

Thanks
David Riddiford

Nov 16 '05 #1
0 1120

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris | last post by:
I have seen the posts on various places on the internet about .NET framework mismatch issues and I don't think that is my problem. ; ) When I execute the following C++.NET code: String...
0
by: Bnaya | last post by:
I'm invoking the same Dll from Console application and WinForm application Both signed with SrongName. the class that I'm invoking is protected with StrongNameIdentityPermission Demand
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
2
by: James Hadwen | last post by:
I'm not sure whether I'm doing something wrong, or StrongNameIdentityPermission just doesn't work in 2.0 beta 2 yet. public class Class1 { public Class1() {...
2
by: | last post by:
I am having a little bit of trouble with the syntax using attributes in classes. The compiler always complaints (VC ++ 2002) on StrongNameIdentityPermission. :-( The intention is secure my...
6
by: Brad | last post by:
I've just used StrongNameIdentityPermission at the class level and it works fine. Can I use it similar to the following for the entire assembly?...
0
by: Simon Hart | last post by:
I can't seem to get this to work. I have applied the above attribute to a class library thats installed in the GAC. I am trying to use this shared assembly from a C# ASP.NET web form, but I am...
0
by: archana | last post by:
Hi all, I am having application in 2003 where i have one class library and two console application. In class library i have one class to which i set strongnameidentitypermission. When i try...
2
by: Ares Chen | last post by:
Hi, all In .NET 1.1, I can protect my assembly by use "StrongNameIdentityPermission", so only the caller with the special StrongName Sign can call my functions in the important assembly. But how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.