I have two different libraries which refereed the base library called base.dll. One library using for web platforms another one using for windows platform (WPF). I have to restrict restrict one public property in WPF platform but I want to access it in web platform. How can achieve this? I am trying condition compilation but I don’t know how to do exactly. Please help me
For Ex:- Base library:
public Class CommonClass{
public string CssClass
{
get;
set;
}
}
Referenced Library 1 (Web) – Referenced the base library, need to access CssClass in this library
Referenced Library 2: (WPF) - Referenced the base library, need to restrict CssClass in this library
This actually sounds like a design flaw. You create a library and define which properties should be accessible by users of that library. Normally you don't hide specific properties from specific clients.
However, I think you can achieve what you want by making the property
internal
and use theInternalsVisibleToAttribute
in yourbase.dll
:This way no client can see that property, except those mentioned in a
InternalsVisibleTo
attribute.See also: Friend Assemblies (C# and Visual Basic)