Rules:
- All types visible for this assembly must be declared in the assemblies referenced by this assembly.
Unless your class library actually expands the types found in Microsoft.Owin.Security.Cookies in its open API, then other assemblies can safely compile your DLL without reference to this assembly.
- A related assembly should not be present at runtime, unless the code in this assembly is really needed, that is, some other code tries to call this code.
In general, this means that as long as other assemblies that reference your assembly and that do not reference Microsoft.Owin.Security.Cookies also do not call any code in your assembly, which would then try to call the code in Microsoft.Owin.Security.Cookies that the assembly should not be present at run time.
The hard part of this second point is that what constitutes the "call code in Microsoft.Owin.Security.Cookies " is not always explicit. As a rule, until you get access to assembly types at all, .NET will not try to execute any code in this assembly. But it’s easy to accidentally access these types, even if they are not necessary (for example, in initializers, static or otherwise, code that checks the implementation of the interface, etc.).
If you really want your clients to be able to use your DLL that references Microsoft.Owin.Security.Cookies , it is not necessary that this DLL is present at run time, you need to be very careful to make sure that you fully support this script It can be done, but it’s also not difficult to make a mistake.
(I must admit, I am surprised that this useful question has not yet been addressed in “Stack Overflow.” It seems like it would be so far. But I could not find a duplicate, hence the answer above. Does anyone know about the duplicate, which I forgot, I welcome any relevant notice of this.)
source share