Calling C# Assembly

PowerBuilder applications can directly call C# assemblies, via two objects: CSharpAssembly and CSharpObject. CSharpAssembly is used to load the C# assembly, and CSharpObject is used to map to the C# class in the assembly. After you create CSharpAssembly and CSharpObject instances in PowerBuilder, you can directly call the functions defined in the C# class.

To help developers write scripts in a more productive way, a tool called "C# Class Importer" is provided to help developers write scripts to correctly call functions in the C# class. C# Class Importer can import the names and data types of the C# classes, functions, properties, and parameters from the C# assembly to the application PBL. It creates the CSharpObject object as an NVO for each C# class and then imports the C# functions to the NVO. After that the developer can write scripts to call the NVO and function directly to execute the corresponding C# code.

For more details, refer to Calling C# Assembly in an Application in Application Techniques, the section called “CSharpAssembly object” in Objects and Controls, and the section called “CSharpObject object” in Objects and Controls.