Restricting access to Assembly.LoadFrom call within an assembly based on strong names

  • Thread starter Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date Start date
N

Nicholas Paldino [.NET/C# MVP]

Surya,

You aren't going to be able to do this. You are going to have to
implement a load mechanism yourself and then have all of your code go
through that mechanism.

Hope this helps.
 
Hi,

I use the Assembly.LoadFrom call in my code to load assemblies dynamically.
This call currently loads both signed and unsigned assemblies.
It now needs to be changed to load only signed assemblies. Again only those
signed assemblies with known public keys need to be loaded.
Is there an easy way to implement this?

Regards
Surya
 
Nicholas,

Thanks for the reply.

Can I get the public key of a signed assembly at runtime using the Evidence
of the assembly? This would help in determining whether the assembly can be
trusted.

Regards
Surya

Nicholas Paldino said:
Surya,

You aren't going to be able to do this. You are going to have to
implement a load mechanism yourself and then have all of your code go
through that mechanism.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

surya said:
Hi,

I use the Assembly.LoadFrom call in my code to load assemblies dynamically.
This call currently loads both signed and unsigned assemblies.
It now needs to be changed to load only signed assemblies. Again only those
signed assemblies with known public keys need to be loaded.
Is there an easy way to implement this?

Regards
Surya
 
Surya,

You can get this by using the Assembly class instance that represents
the Assembly. The Name property will expose an AssemblyName instance. From
there, you can call the GetPublicKey method on the AssemblyName instance and
get the key.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

surya said:
Nicholas,

Thanks for the reply.

Can I get the public key of a signed assembly at runtime using the Evidence
of the assembly? This would help in determining whether the assembly can be
trusted.

Regards
Surya

message news:[email protected]...
Surya,

You aren't going to be able to do this. You are going to have to
implement a load mechanism yourself and then have all of your code go
through that mechanism.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

surya said:
Hi,

I use the Assembly.LoadFrom call in my code to load assemblies dynamically.
This call currently loads both signed and unsigned assemblies.
It now needs to be changed to load only signed assemblies. Again only those
signed assemblies with known public keys need to be loaded.
Is there an easy way to implement this?

Regards
Surya
 
Back
Top