DotNet::Services.RegisterNamespace Method

Syntax

dim Result as L = RegisterNamespace(ParentNamespace as C, AssemblyNamespace as C, Assembly as DotNet::AssemblyReference)

Arguments

ParentNameSpaceCharacter

If an empty string is provided, the class is registered under the "DotNet" namespace.

AssemblyNamespaceCharacter

 

AssemblyDotNet::AssemblyReference

 

Returns

ResultLogical

Returns .t. or .f. whether or not the operation succeeds. The DotNet::Services CallResult property will contain additional information about the error.

Description

Connects a .NET namespace within an assembly, and all of its classes, to the Alpha Anywhere type system

Discussion

RegisterNamespace() connects a .NET namespace within an assembly, and all of its classes, to the Alpha Anywhere type system within an Xbasic namespace.

The basic idea is that you can "register" a .NET assembly in an Alpha Anywhere namespace and use it as if it were built in. This type can be dimmed in any script after the type is registered. This can be useful where you only want a single namespace tree from an assembly to be visible, or when you have an assembly with multiple namespaces that belong in different trees. Once the assembly namespace is registered, which is required once per execution of Alpha Anywhere, instances can be DIMmed for each of its classes in any script.

 Example

Adding an assembly namespace from the global assembly cache to the Xbasic type system.

Dim Assy as DotNet::AssemblyReference
Dim Services as DotNet::Services
Dim SourceNamespace as C = "SourceNamespaceInAssembly"
 
Assy.Name = "SampleAssembly"
Assy.Version = "1.0.2004.0"
Assy.Culture = "neutral"
Assy.PublicKeyToken = "8744b20f8da049e3"
 
If .not. Services.RegisterNamespace("MyNameSpace", SourceNamespace, Assy) 
    UI_Msg_Box("Error registering assembly namespace " + SourceNamespace + " in " + Assy.Name, Services.CallResult.Text)
    End 
End if
 
Dim Instance as MyNameSpace::SourceNamespaceInAssembly::MyClass