Issue calling new CGX_Net from standalone program

I recently upgraded Montaj, and a C# dotnet standalone program has stopped working, in the call to new CGX_NET in the final line of the following code snippet:

//IntPtr hWnd = (IntPtr)Windows.


//IntPtr handle = Process.GetCurrentProcess().MainWindowHandle;


//NativeWindow nativeWindow = new NativeWindow();


//nativeWindow.AssignHandle(handle);


// var hwnd = new WindowInteropHelper(handle).Handle;

// Pro
//string dllPath = "geosoft.desktop.gxnet.dll";

// Assembly desktoGxNet = Assembly.LoadFrom(dllPath);


//dllPath = "geoengine.core.gxnet.dll";


//Assembly coreGxNet = Assembly.LoadFrom(dllPath);


// dllPath = "GeoEngine.Core.Managed.dll";


// // Assembly coreManaged = Assembly.LoadFrom(dllPath);


pGeo = new CGX_NET("SvMgr", "V1", 2047, null, 0);

The commented-out code runs fine, verifying that paths and DLLs are in the correct places, and load just fine. I left it in this post just to indicate that I've taken those steps.a

The code throws no exceptions, but rather, after bout 5 seconds, the entire c# program exits with the following error return value: 0x80000003.

This is running on a system with Montaj running correctly. The failure happens whether Montaj is active or not.

A Google search for that error code returns a bunch of results about programs trying to display a dialog, and is failing because of that. The behavior (including the 5-second pause) is consistent with an authentication failure, at which point the library might throw up an error dialog. But the Montaj/Seequent login is fine.

Does this ring any bells? Has something changed about authentication? Does this program need to use some other authentication (have I seen a notice about the "Bentley sign-in", in contrast to the legacy Seequent login?).

Any advice would be appreciated.

Thanks,

Bob Cram

Geometrics

Answers

  • SerbanMarin1
    SerbanMarin1 Posts: 4 Staff

    Hi Bob, can you please give us some more context?

    1. What version are you upgrading to and from?
    2. Are you running in the command line or debugging in VS?
    3. Are you seeing any error in Windows Event Viewer at the moment the application crashes?

    The error seems like an assembly mismatch. The two assemblies you are loading are C#. Is there a reason they are being loaded dynamically instead of referenced as dependencies to the project?

  • Thanks for replying. I updated from Montaj 2022 to the current version.

    The standalone program is a C# .net UI program.

    What's interesting is that it doesn't appear to be a crash - a number of threads exit, then the program exits.

    The dynamic references were there simply for testing - dynamically loading provides more granular information about DLL loading. The call that causes the program exit is to code loaded via dependency.

    I am looking at questions of assembly mismatch. A decent candidate is that the .net framework or SDK is not in synch with the libraries in the new Montaj install.

  • Here is additional UI information from the crash:

    [Thread 0] (Current)

    pCreate_GEO  gxx_geo.cpp (707)

    H_AP::sCreate ap.cpp {1232}

    H_AP::sSharedCreate ap.cpp {1107}

    H_AP::sInternalCreate ap.cpp {452}

    H_AP::InitDotNet ap.cpp {452}

    AbortCode = A1SW6M8

  • This issue was resolved by updating Montaj to version 2025.2.

    It is also a requirement that the standalone C# program be built to .NET 8.0.