Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a signed application use an unsigned assembly (which can be regenerated at customer sites)

Tags:

c#

My C# .net executable needs to be signed in order to use one of the methods in another of our assemblies that provides access to a password.

That same executable needs to reference and use an assembly that is not signed. The reason it is not signed is we provide a way for customers to regenerate it on site (it wraps access to modelled customizations in the app).

Is there any way the single executable can make use of both the signed and unsigned assemblies?

like image 944
Darrin Doherty Avatar asked Dec 27 '22 09:12

Darrin Doherty


2 Answers

You can't reference unsigned assembly from signed assembly, but you can easily Load one using one of Assembly.Load methods.

Usually you provide interface (or base class if you like) in signed assembly and use that throughout code to obtain information at compile time. Customer's unsigned assembly (plugin) implements that interface on some specially marked class. Than your application loads the assembly (either from default location via Load, or from specified file via LoadFile), finds and constructs the class than uses it to obtain information at run-time.

Note: You may also look into "how to implement plugins in C#/.Net" questions for approaches.

like image 104
Alexei Levenkov Avatar answered May 13 '23 20:05

Alexei Levenkov


I believe the only way for you to use an unsigned assembly is to load it at runtime using reflection.

You cannot a add strong name to your executable if it references something which is not strongly named.

like image 41
Igor Korkhov Avatar answered May 13 '23 21:05

Igor Korkhov