Actually, BindToMoniker solves the issue for obtaining an Interop Application Object. It's available in 4.8 .Net Framework and 6.0/.Net Core. Using this api is what I converged to.
From my understanding there are few issues:
- Identifying the app to Marshel to
- Obtaining the Marshal Object for interop
GetActiveObject, while it works, from other's questions/answers will only give the active object (which becomes a problem when there is more than on process running for the app in question), and only works in 4.8 .Net Framework.
When I used GetActiveObject I did the following:
acApp = new Application();
acApp = (Application)Marshal.GetActiveObject("Access.Application");
While this worked fine, I needed to establish a two process model as the core app with the data to send to the Interop App was built in 6.0. One process built with 4.8 providing the Application control I desired and an RPC conduit to another 6.0 built process. The other process built with 6.0 RPC'd the desired data to be used in the Application Control. This worked fine, albeit with working set size increased, delays for the RPC transfers, and left the issue when there was more than one Application running unaddressed.
The other technique I found was to instead use:
acApp = new Application();
acApp = (Application)Marshal.BindToMoniker(_conf.Moniker);
where "_conf.Moniker" was a string sent to the process identifying the file used by the presently running application. BindToMoniker eliminated the need to use 4.8 entirely. I sent this string on the command line from the app, which started the Net6.0 app. The VBA I used to pass the filename used within the Application looked like:
AppToRun = "the60Netapp" & " -f " & """" & CurrentProject.FullName
ProcessID = Shell(AppToRun, 0)
I saved the ProcessID to enable me to later end the process. The BindToMoniker helped resolve both the identification issue and how to keep the .Net entirely 6.0 (or what ever Framework is desired).