• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    *Tony Tanzillo

    Assembly attributes and visibility

    68 Views, 1 Replies
    08-31-2005 08:55 PM
    I don't like the design of the two aforementioned assembly
    attributes, because I have no way to prevent someone from
    calling my IExtensionApplication.Initialize member through
    reflection. My simple test code shows that I can find every
    single loaded assembly, and invoke its Initialize() function.

    That's not good. How can I make my Initialize() function
    callable from no place other than the runtime?

    This might work, but I don't like it at all:

    public void Initialize()
    {
    string caller = Assembly.GetCallingAssembly().GetName().Name;
    if( string.Compare(caller, "acdbmgd") != 0 )
    throw new InvalidOperationException("Get lost, Bozo.");
    foreach( Assembly asm in AppDomain.CurrentDomain.GetAssemblies() )
    if( asm.IsDefined(typeof(ExtensionApplicationInfoAttribute), false) )
    ProcessAssembly( asm );
    }


    --
    http://www.caddzone.com

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
    http://www.acadxtabs.com
    Please use plain text.
    *Albert Szilvasy

    Re: Assembly attributes and visibility

    08-31-2005 09:51 PM in reply to: *Tony Tanzillo
    I don't think that there's anything more elegant than this today. All .net
    code we load is fully trusted. We might change this in the future so that
    plugins will be loaded with minimal trust (no reflection).

    Albert

    "Tony Tanzillo" wrote in message
    news:4944872@discussion.autodesk.com...
    I don't like the design of the two aforementioned assembly
    attributes, because I have no way to prevent someone from
    calling my IExtensionApplication.Initialize member through
    reflection. My simple test code shows that I can find every
    single loaded assembly, and invoke its Initialize() function.

    That's not good. How can I make my Initialize() function
    callable from no place other than the runtime?

    This might work, but I don't like it at all:

    public void Initialize()
    {
    string caller = Assembly.GetCallingAssembly().GetName().Name;
    if( string.Compare(caller, "acdbmgd") != 0 )
    throw new InvalidOperationException("Get lost, Bozo.");
    foreach( Assembly asm in AppDomain.CurrentDomain.GetAssemblies() )
    if( asm.IsDefined(typeof(ExtensionApplicationInfoAttribute), false) )
    ProcessAssembly( asm );
    }


    --
    http://www.caddzone.com

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
    http://www.acadxtabs.com
    Please use plain text.