Create an Assembly

Assemblies work similarly to Visual Studio Code. There is a project with folders that each contain dependencies, such as assemblies and business rules. Assemblies enable developers to add references to known packages that are part of the standard server install, such as OpenXML. In the OneStream application, assemblies are located within maintenance units.

TIP: If you need to reference an assembly from a business rule, use the following syntax: WS\ followed by the long Workspace assembly name. For example: WS\Workspace.wsName.wsAssemblyName

Create a Workspace Assembly Using Visual Basic

NOTE: Assemblies can be C# or Visual Basic.

  1. Go to the Workspace and maintenance unit to create the assembly.

  2. Select the Assemblies node to expand it.

    NOTE: You will not see this option in the default maintenance unit, which is located in the Default Workspace. This maintenance unit only stores Cube View groups.

  3. On the toolbar, select the Create Assembly icon.

    Highlighted create assembly icon in toolbar is stacked pages, flat design style.

  4. On the Assembly Properties tab, for the Compiler Language field, in the drop-down menu, select the type of assembly: C# or Visual Basic.

    Assembly Properties tab open displaying the Compiler Language field and drop-down menu

  5. Name the assembly.

  6. Select the Save icon.

Create an Assembly File

The assembly file is where you write the logic. You can choose to write a business rule type or a rule of your own. Writing a custom rule provides greater flexibility and is the preferred option for most developers. It can also improve performance.

  1. Select an assembly, then select the Assembly Files tab.

  2. Right-click on Files, and select Add File.

    Assembly Files tab open with Files drop-down menu showing the Add File option

  3. In the Add File dialog box, complete these fields:

    1. In the File Name field, enter a name for the file.

    2. In the Source Code Type drop-down menu, select Business Rule or Service Type.

    3. In the Compiler Action drop-down menu, select an option.

      • (Use Default) or Compile: These options will compile the file when the assembly is compiled.

      • Disabled: This option will not compile the assembly to verify syntax.

  4. Select the OK button.

  5. In the toolbar, select the Save icon. The Workspace will look similar to the following image.

    In the Workspace navigation tree on the left, a Maintenance Unit is selected with the Assemblies section expanded to show a selected assembly file named NewFile. The middle pane lists the assembly files, and the code editor on the right displays the C# source code for the selected file.

    NOTE: On the Assembly Files tab, you can change the Compiler Action option, but you cannot change the Business Rule Type. To change the Business Rule Type, you must delete the file and recreate it.

Delete an Assembly File

  1. Select the assembly file to delete.

  2. On the Assembly Properties tab, select the Delete icon.

Encrypt an Assembly File

Encryption protects assembly files from users who may have access to a Workspace. Security can be controlled in the following ways:

  • Workspace level (access and maintenance security)

  • Maintenance unit level (access and maintenance security)

  • Application security roles that prevent others from writing assemblies in the Application Workspaces page (AdministerApplicationWorkspaceAssemblies)

  • System security roles that prevent others from writing assemblies in the System Workspaces page (SystemApplicationWorkspaceAssemblies)

You must be a member of the EncryptBusinessRules security role group to encrypt assembly files. Within Workspace assemblies, you can create rules using C# or Visual Basic.

  1. Right-click on the assembly file name.

  2. Select Encrypt File.

  3. In the Encrypt File dialog box, enter a password for encryption using the legacy rules.

  4. Select the OK button.

You can also decrypt files by right-clicking on the encrypted file, selecting Decrypt File, and then entering the previously created password.

Create an Assembly Folder

Create assembly folders to organize your assembly files.

  1. Select the assembly, then select the Assembly Files tab.

  2. Right-click on Files, and select Add Folder.

  3. Name the folder, then select the OK button.

  4. (Optional) To add files to the folder, right-click on the folder and select Add File.

    NOTE: You cannot drag and drop files into a folder.

Create a Dependency

Dependencies are useful when you have methods within other assemblies or business rules.

  1. Select the assembly, then select the Assembly Files tab.

  2. Right-click on Dependencies, and select Add Dependency.

  3. In the Dependency Type drop-down menu, select an option:

    • Workspace Assembly: Select this option if other assemblies might be included in the Workspace. If you create a dependency with another Workspace, you must provide the Shared Workspace Name, and this Workspace must have the Is Shareable Workspace property set to True.

      The following example shows the dependency setup. Multiple Workspaces can be entered in a comma-separated list.

      In the Workspace navigation tree on the left, an assembly is highlighted named NewFile. The Assembly Files view tab shows a dependency selected named New, and the Dependency properties panel displays the dependency type as Workspace Assembly, the shared Workspace name is CB 1, and Dependency name is new.

      NOTE: To create a dependency within the same Workspace, leave the Shared Workspace Name field blank.

    • Prepackaged Assembly: Select this option to use the assembly that is automatically included with OneStream.

    • Business Rule: Select this option to create dependencies with any business rules located on the Business Rules page. In the Dependency Name field, enter the name of the business rule.

  4. In the toolbar, select the Save icon.

After creating dependencies, you might receive an error when compiling the assembly if something is incorrect within the assembly or dependency itself.

These are important notes to be aware of when compiling with assemblies:

  • If the Compiler Action is set to Disabled for any dependent assembly file, you will not see an error even if there are issues wtih the syntax. For example, the following dependent assembly would not produce a syntax error even though one is present.

    Green arrow pointing to lack of syntax error on highlighted lines 28-29

  • Properties on the Assembly Files tab require you to enter the exact name of the Workspace, assembly, and business rule. If they are incorrect, you will receive a compile error.