.NET types visibility in assembly packages
As part of the app functionality development, you might need to use source code (*.cs) and/or executable code (*.dll) of another package in a user-made package. To ensure that functionality of assembly packages works as expected, consider type visibility when you use code from another packages. To make source code of an assembly package visible for other package, set the IsPublic
property listed in the descriptor.json
file to true
.
Since Creatio adds assembly package to the project during the compilation, some functions are applied only after compilation.
Creatio lets you organize the app structure in multiple ways. Consider the app structure when you use source code from one package in another package.
Package can include the following file content:
- External assembly packages. Creatio stores external assembly packages in the
Assemblies
directory. - Assembly packages. Learn more: Assembly package. Creatio stores assembly packages in the
Files
directory. - Project packages. Learn more: Project package. Creatio stores project packages in the
Files
directory. - Source code type schemas. Learn more: Configuration elements of the Source code type. Creatio stores Source code type schemas in the
Schemas
directory.
Type visibility inside a single package
For example, package has the structure shown in the figure below.
After compiling the package, Creatio compiles the project source code (Files
directory) and schema source code (Schemas
directory) into the <YourPackageName>.dll
library (Files\bin
directory).
*.csproj
project of the package automatically references all external libraries imported into the package. Instructions: Assembly package structure and dependencies. After that, the types from the external library are visible to the assembly package.
In this case, type visibility is as follows:
- The types of the assembly package project (
Class_2.cs
) and types of the source code schema (SourceCodeSchema.cs
) are both visible to each other. - Types of an external library are visible if you connect the assembly package to the
*.csproj
project of the package.
Import external libraries using the Configuration section. Do not add external libraries to the Files
directory directly or connect them to the *.csproj
project of the package manually. This causes assembly packages to load into the app domain incorrectly and might cause compatibility issues.
Type visibility between multiple packages
For example, packages have the structure shown in the figure below.
In this case, type visibility is as follows:
- When packages are inherited, the project of an assembly package automatically receives a link to the parent resources after compilation. This connection is only possible within one level of package hierarchy.
- External assembly libraries are visible to inheritors if the
IsPublic
property listed in thedescriptor.json
file is set totrue
.