.NET

Reply
*Tony Tanzillo
Message 1 of 2 (78 Views)

Assembly attributes and visibility

78 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
*Albert Szilvasy
Message 2 of 2 (78 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community