Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC: Use X# code in VO app

Use X# code in VO app 1 month 2 weeks ago #12093

  hsc's Avatar Topic Author hsc Offline Posts: 121
Hi All,

I would need to insert a module written in XSharp core dialect, into an older VO application. Does anyone have experience? Any advice good


Please Log in or Create an account to join the conversation.

Use X# code in VO app 1 month 2 weeks ago #12094

  wriedmann's Avatar wriedmann Offline Posts: 2030
Hi Juraj,

GUI or GUI-less?
If you can make that GUI-less, COM may be the best choice.
Nearly all my VO applications are now using at least one COM module in X#.
You can find details and samples here:

Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Use X# code in VO app 1 month 2 weeks ago #12095

  Jamal's Avatar Jamal Offline Posts: 192
Hi Juraj,

This is my approach. Tested and it works. Adjust any file paths accordingly.

Run Visual Studio as an administrator; this is for critical for assembly registration.

In Solution Explorer, click Properties, then double click AssemblyInfo.prg.

Add the following to proper sections in the AssemblyInfo.prg.

using System.Runtime.InteropServices

[assembly: ComVisible(true)]
[assembly: Guid("BAEB8513-5171-4AF7-A963-75085462232")]

Edit: Robert will automate the above in the next build just like in C#. Will update post when I have may hands on it and confirm functionality.

Change the GUID. To obtain a unique GUID, click the Visual Studio Tools menu, choose Create GUID. Keep default in registry format. Then Copy and Paste and replace above and remove the { } from the copied string.

Here is an example of the X# code:
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
using System.Windows.Forms   // just for this sample. Add to project references.
using System.Runtime.InteropServices

	public CLASS Test
   public method SayHello() as void 


In the Build Event, Post-build Event Command Line:
add .NET regasm.exe to register the assembly. For example: C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\test\XSharpVOClassLibraryCOM\bin\Release\XSharpVOClassLibraryCOM.dll" /tlb

Build your project in release mode.

Now, VS should display something similar to the following in the build output window:

Build started: Project: XSharpVOClassLibraryCOM, Configuration: Release Any CPU
XSharpVOClassLibraryCOM -> C:\test\XSharpVOClassLibraryCOM\bin\Release\XSharpVOClassLibraryCOM.dll
Microsoft .NET Framework Assembly Registration Utility version 4.8.3752.0
for Microsoft .NET Framework version 4.8.3752.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types registered successfully
Assembly exported to 'C:\test\XSharpVOClassLibraryCOM\bin\Release\XSharpVOClassLibraryCOM.tlb', and the type library was registered successfully

In VO, go to Tools menu, select Automation Server and find the XSharpVOClassLibraryCOM class and generate the _Test class.

Test in VO:
METHOD XSharpCOM_Call_Button( ) CLASS MyForm
   local t := _Test{} as _Test
   t := null_object

Make sure you copy the BIN\Release\ DLLs to your VO app exe folder.

Note: if you distribute your VO app, you must regasm the COM DLL as an admin.

Good luck.


Please Log in or Create an account to join the conversation.

Last edit: by Jamal.
  • Page:
  • 1