.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
*Tony Tanzillo
Assembly attributes and visibility
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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(ExtensionApplicationInfoAttri bute), false) )
ProcessAssembly( asm );
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
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(ExtensionApplicationInfoAttri
ProcessAssembly( asm );
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
*Albert Szilvasy
Re: Assembly attributes and visibility
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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(ExtensionApplicationInfoAttri bute), false) )
ProcessAssembly( asm );
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
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"
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(ExtensionApplicationInfoAttri
ProcessAssembly( asm );
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

