.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly attributes and visibility

1 REPLY 1
Reply
Message 1 of 2
Anonymous
283 Views, 1 Reply

Assembly attributes and visibility

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
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost