mercredi 6 octobre 2021

Getting the assembly name of the first reference in a chain of reference

I'm trying to allow a user (programmer) to configure an assembly they'd use in their project by adding some information to appsettings.json.

Here's an example or reference a programmer could make:

CustomProject->ProxyA->FrameworkClass

From FrameworkClass, I would like to retrieve ProxyA's assembly name.

So that way, I can allow a programmer to add a JSON node called ProxyA to CustomProject's appsettings.json that I can retrieve from FrameworkClass.

I want to do something like this, because CustomProject could have references setup like this

CustomProject->ProxyA->FrameworkClass
CustomProject->ProxyB->FrameworkClass

FrameWorkClass will need different configuration in both cases.

I tried Assembly.GetExecutingAssembly(), Assembly.GetEntryAssembly() and Assembly.GetCallingAssemble() and ProxyA or ProxyB never show, really.

Is there any way to do that ? Or what other approach should I take ?





Aucun commentaire:

Enregistrer un commentaire