Click here to Skip to main content
16,006,013 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How do I handle events for dropdown menu items created on the fly? Pin
Tarakeshwar Reddy20-Dec-06 21:30
professionalTarakeshwar Reddy20-Dec-06 21:30 
GeneralRe: How do I handle events for dropdown menu items created on the fly? Pin
JoeRip20-Dec-06 21:49
JoeRip20-Dec-06 21:49 
GeneralRe: How do I handle events for dropdown menu items created on the fly? Pin
Tarakeshwar Reddy20-Dec-06 22:00
professionalTarakeshwar Reddy20-Dec-06 22:00 
QuestionSharing data across threads Pin
Hendrik Debedts20-Dec-06 4:09
Hendrik Debedts20-Dec-06 4:09 
AnswerRe: Sharing data across threads Pin
Keith Malwitz20-Dec-06 6:03
Keith Malwitz20-Dec-06 6:03 
GeneralRe: Sharing data across threads Pin
Hendrik Debedts20-Dec-06 23:35
Hendrik Debedts20-Dec-06 23:35 
QuestionShockwave Flash Component in visual studio 2005 Pin
morteza5719-Dec-06 23:37
morteza5719-Dec-06 23:37 
QuestionGetting reference of calling Assembly. Pin
Syed Muhammad Kamran19-Dec-06 18:55
Syed Muhammad Kamran19-Dec-06 18:55 
How can I get a reference of the calling Assembly at Runtime?

I've an assembly (RestrictedAssembly) and I want to ristrict access to it means no user who

fullfills my criteria (in my case not having my desired public key token for assembly) can

instantiate any type from my assembly.

For better understanding, this is what I am trying to do.

I've generated a public/private keypair file for myself, then I use it to sign all those assemblies

which I want to allow Access to my RestrictedAssembly. On Runtime before instantiating any type from

RestrictedAssembly, in constructor I am asking the caller to provide a Type object from which he's

initiating a call to constructor. For example.

/**
 * Constructor of public sealed class RestrictedType1
 * Cotains in RestrictedAssembly.
 * Caller is required to pass a type object
 * o is the Type who wish to instantiate this class.
 */
public RestrictedType1(Type o) {
   Type t = this.GetType ();
   byte [] t1Token = o.Assembly.GetName().GetPublicKeyToken();
   byte [] t2Token = t.Assembly.GetName().GetPublicKeyToken();
   AccessNotAllowedEx ex = new AccessNotAllowedEx("Not Allowed");
   
   if(t1Token != null && t2Token != null) {			
      if(t1Token.Length == t2Token.Length) {
         for(int i = 0; i< t1Token.Length; i++) { 
            if (t1Token[i] == t2Token[i]) 
               continue; 
            else 
               throw ex;
         }
         // If get here successfullyDone;
         ex = null;                    
      } else 
         throw ex;
   } else 
      throw ex;
}


I am checking, if the public key tokens for both the calling and called assemblies are identical and

if they are, then I am allowing the caller to instantiate my RestrictedType other wise I raise an

exception.

Now the problem with this approach is that, suppose I've an Assembly CallerOfRestrictedAssembly and

I've signed it with my public/private key pair. Now from CallerOfRestrictedAssembly it is valid to

do the following. Since both assemblies have same public key token.

RestrictedType1 res = new RestrictedType1(this.GetType);


However, suppose if some one initiate a call to RestrictedType1 constructor

RestrictedType1 res = new RestrictedType1(typeof(TypeFromCallerOfRestrictedAssembly));


This will cheat the constructor. Thus, I don't want caller to Pass Type argument into Constructor.

and depend on it. What I am looking for is to get a reference of Calling Assembly into my

RestrictedAssembly at Runtime?

I'll apreciate if some can help with this or any other approach to achieve this level of code

restriction? Thanks.

SMK
GeneralRe: Getting reference of calling Assembly. Pin
Guffa19-Dec-06 19:17
Guffa19-Dec-06 19:17 
QuestionExecutionContext Pin
Hendrik Debedts19-Dec-06 12:19
Hendrik Debedts19-Dec-06 12:19 
QuestionDetermining Memory Footprint of a filled Dataset Pin
Keith Malwitz19-Dec-06 6:25
Keith Malwitz19-Dec-06 6:25 
QuestionARCHITECTURAL DIFFERENCE between .net 1.0 and 2.0? Pin
karam chandrabose19-Dec-06 0:40
karam chandrabose19-Dec-06 0:40 
AnswerRe: ARCHITECTURAL DIFFERENCE between .net 1.0 and 2.0? Pin
Paul Conrad19-Dec-06 5:59
professionalPaul Conrad19-Dec-06 5:59 
AnswerRe: ARCHITECTURAL DIFFERENCE between .net 1.0 and 2.0? Pin
Pete O'Hanlon19-Dec-06 11:32
mvePete O'Hanlon19-Dec-06 11:32 
QuestionGUI Interface of a service Pin
christopheL19-Dec-06 0:23
christopheL19-Dec-06 0:23 
AnswerRe: GUI Interface of a service Pin
PIEBALDconsult19-Dec-06 3:22
mvePIEBALDconsult19-Dec-06 3:22 
GeneralRe: GUI Interface of a service Pin
christopheL19-Dec-06 3:58
christopheL19-Dec-06 3:58 
QuestionHow to Edit a Data Grid, using Text Box or Combobox Pin
Kushwaha2k18-Dec-06 23:53
Kushwaha2k18-Dec-06 23:53 
AnswerRe: How to Edit a Data Grid, using Text Box or Combobox Pin
kinnuP20-Dec-06 0:28
kinnuP20-Dec-06 0:28 
Questionseparate .config file Pin
knez18-Dec-06 23:05
knez18-Dec-06 23:05 
Question.Net:Globalization and SQL:Collate Pin
enduro1x18-Dec-06 18:42
enduro1x18-Dec-06 18:42 
QuestionNo Touch Deployment vs ClickOnce Deployment Pin
KreativeKai18-Dec-06 6:02
professionalKreativeKai18-Dec-06 6:02 
QuestionGetting to know WCF questions. Pin
Snowjim17-Dec-06 22:38
Snowjim17-Dec-06 22:38 
Questionclasses Pin
chinnivinay17-Dec-06 19:38
chinnivinay17-Dec-06 19:38 
AnswerRe: classes Pin
Guffa17-Dec-06 21:28
Guffa17-Dec-06 21:28 

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.