C# - Ensuring an assembly is called via a specified assembly
- by Adam Driscoll
Is there any built in functionality to determine if an assembly is being called from a particular assembly?
I have assembly A which references assembly B. Assembly A exposes PowerShell cmdlets and outputs types that are found within B. Certain methods and properties with in types of exposed by B are of interest to types in assembly A but not of interest to consumers of PowerShell or anyone attempting to load types in B directly and call methods within it.
I have looked into InternalsVisibleToAttribute but it would require extensive rework because of the use of interfaces. I was devising a shared key system that would later be obfuscated but that seemed clunky.
Is there any way to ensure B is called only by A?