Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jan 06, 2016 10:45 pm Post subject: Making included Infralution.Licensing.WPF classes private |
|
|
By default when you include the source code for the Infralution.Licensing classes in your own project they not declared as public unless you define the ILS_PUBLIC_CLASS compilation constant. If you are building a component (DLL) this is desirable as it means the licensing classes are not accessible to your users (for applications it is not really important). Unfortunately in the WPF implementation this is difficult because the WPF XAML designer generates a hidden partial class and sets the access modifier to "public" by default. This means you will get compilation errors if you don't set ILS_PUBLIC_CLASS constant, because public classes are not allowed to have methods which use private types. For this reason the instructions for including the WPF source code in your own project recommend defining the ILS_PUBLIC_CLASS compilation constant.
If you are using ILS to license an assembly (DLL) then this may not be desirable and you can take the following steps to compile the licensing classes as internal (friend) to the assembly.
VB.NET
1. Remove the ILS_PUBLIC_CLASS compilation constant
2. Add the following attribute to the XAML Window declaration for each of the *.xaml files:
Code: | x:ClassModifier="Friend" |
3. Select the Project "Show all Files" option to ensure you can see the hidden designer files for the project
4. Expand the *.xaml and *.resx file nodes to show the dependent files
5. Remove the "Public" access modifiers from each of the classes in the *.xaml.vb, *.Designer.vb and *.ResourceWrapper.vb files
C#
1. Remove the ILS_PUBLIC_CLASS compilation constant
2. Add the following attribute to the XAML Window declaration for each of the *.xaml files:
Code: | x:ClassModifier="internal" |
3. Select the Project "Show all Files" option to ensure you can see the hidden designer files for the project
4. Expand the *.xaml and *.resx file nodes to show the dependent files
5. Remove the "public" access modifiers from each of the classes in the *.xaml.cs, *.Designer.cs and *.ResourceWrapper.cs files
The code should now build without errors and the classes will now be private to the assembly _________________ Infralution Support |
|