Referencing Dependency Classes in Code
Once you've set up assembly dependencies, you can reference the dependency's classes directly in your VB.NET or C# code using the compiled namespace.
Compiled Namespace Pattern
Every workspace assembly file compiles into a namespace following this pattern:
Where:
- NamespacePrefix — the workspace's
Namespace Prefixproperty (found in workspace properties). If blank, defaults to the workspace name (sanitized). For the Default workspace, this is alwaysDefault. - AssemblyName — the name of the assembly (sanitized — no spaces)
Each file in the assembly becomes a class within that namespace.
Fully Qualified Reference
Using Imports / using Directives
Add an
Imports (VB.NET) or using (C#) line at the top of the file to shorten references:MainClass Example (Dashboard DataSet)
This is the most common pattern — a
MainClass entry point calling into a shared dependency. The DataSet returns a DataTable built from a SQL query and uses a shared utility to format a column value:Referencing Methods on a MainClass From Another Assembly
You can reference a
MainClass from another assembly the same way you'd reference any other class — it compiles to Workspace.{Prefix}.{Assembly}.MainClass. However, there are important constraints:- Methods must be
Public Shared(VB.NET) /public static(C#) to call them without instantiatingMainClass. TheMainentry point itself is an instance method invoked by the OneStream runtime, so it is not directly callable. - Avoid calling
Maindirectly — it expects runtime-providedargsobjects (e.g.,DashboardDataSetArgs) that are not meant to be constructed manually.
Calling a Shared Helper on MainClass
Suppose assembly
DataSetLib has a file ds_Revenue with a MainClass that includes a reusable helper:From another assembly (with a dependency on
DataSetLib), reference the helper via the MainClass path:Instantiating MainClass (Not Recommended)
If the method you need is a
Public instance method (not Shared), you can instantiate MainClass and call it:Why this is not optimal:
- Unnecessary object allocation.
MainClassis designed to be instantiated once by the OneStream runtime. Creating a second instance allocates memory for an object whose only purpose is to serve as a method container. - Misleading intent. When another developer sees
New ds_Revenue.MainClass(), it looks like you're trying to re-execute that business rule, obscuring the fact that you just need a helper function. - Risk of side effects. If
MainClasshas a constructor or field initializers that assume runtime invocation, instantiating it yourself may produce unexpected behavior. - Fragile coupling. Your code depends on
MainClassremaining instantiable with a parameterless constructor.
Prefer
Public Shared instead. Mark reusable methods as Public Shared (VB.NET) / public static (C#) so callers never need to instantiate MainClass:Extract Shared Logic
If you find yourself needing to call
MainClass methods from other assemblies frequently, consider moving the shared logic into its own file/class. This keeps MainClass focused on its entry-point role and makes dependencies clearer:Both
DataSetLib and Reports depend on SharedLib for reusable logic. Neither needs to reference the other's MainClass.Cross-Workspace References
If the source assembly is in a different workspace (e.g., workspace
SharedWorkspace with Namespace Prefix = Shared), the namespace changes accordingly:Finding a Workspace's Namespace Prefix
To check or set the namespace prefix:
- Go to Application > Presentation > Workspaces
- Select the workspace
- Look at (or set) the Namespace Prefix property
- If the field is blank, the workspace name is used as the prefix
Related Content
- Referencing Assemblies and Sharing Code — Assembly dependency setup and reference syntax for XFBR, Dashboard, CubeView, and Service Factory configurations
- Getting Started with Workspace Assemblies — Workspace hierarchy, assembly structure, and the Service Factory pattern
- Getting Started with Business Rules — Business Rules fundamentals for comparison