Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX Remoting - need help with NXOpenRemotingService example

Status
Not open for further replies.

LHolm

Industrial
Feb 17, 2020
6
I've searched around quite a bit for a solution but haven't found anything that addresses the entire set of restrictions I'm operating under.

A few things to note/the steps I've taken so far:


1) The intention is to find a way to make my employer's ~30 year old GRIP programs work with more modern journals. Long term, they will be replaced, but a few of them use a common function that would be better served as a Journal, so it would be nice to at least get that working until I can get all of the GRIP programs ported over.

GRIP has a "run_journal" function, which, as I understand it, opens a new NX session in "BATCH mode" and attempts to run the specified Journal there. This obviously means that it won't "see" any part/assembly you have open in the session from which you originally ran the GRIP program.

After some research, I found the NXOpen RemotingExample:

\UGOPEN\SampleNXOpenApplications\DotNet\RemotingExample

which seems likely to work, it it weren't for:


2) I don't have an Author License, and it is unlikely that my employer will be convinced to get one. This has thus far not been an issue, since the scripts I write are fairly simple and run easily by playing the journal file that I put together in Notepad++.

When trying to run the NXOpen Remoting Example, however, I ran into "namespace" errors. As I understand it, the "System.Runtime.Remoting.Channels.Http" namespace can't be accessed by default, and needs to be added as a "reference" (most sources I found suggested Visual Studio) before compiling. Since I have no Author License, and run the actual Journal files instead of ever compiling the program in Visual Studio, this doesn't sound like it will work.

After more research, it sounds like it should be possible to load an outside .dll at runtime using System.Reflection instead of adding it as a reference.

Based on what I could piece together, I:

a) replaced lines 119-130 in "C:\Program Files\Siemens\NX2212\UGOPEN\SampleNXOpenApplications\DotNet\RemotingExample\Server\NXOpenRemovingService.cs":
Code:
LifetimeServices.LeaseTime = System.TimeSpan.FromDays(10000);
 
SoapServerFormatterSinkProvider provider = new SoapServerFormatterSinkProvider();
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
 
// Create the IDictionary to set the port on the channel instance.
 
IDictionary props = new Hashtable();
props["port"] = port;
 
// Create a new http channel with the given provider and properties
ChannelServices.RegisterChannel(new HttpChannel(props, null, provider), false);

With:

Code:
Assembly runtimeRemoting = System.Reflection.Assembly.LoadFile(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Runtime.Remoting.dll");
 
Type soapServerProvider = runtimeRemoting.GetType("System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider");
 
var soapInstance = Activator.CreateInstance(soapServerProvider);
 
PropertyInfo typeFilterLevelPropertyInfo = soapServerProvider.GetProperty("TypeFilterLevel");
 
typeFilterLevelPropertyInfo.SetValue(soapInstance, System.Runtime.Serialization.Formatters.TypeFilterLevel.Full, null);
		
// Create the IDictionary to set the port on the channel instance.
 
IDictionary props = new Hashtable();
 
props["port"] = port;
 
// Create a new http channel with the given provider and properties
 
Type httpChannel = runtimeRemoting.GetType("System.Runtime.Remoting.Channels.Http.HttpChannel");
		
channelInstance = (IChannel)Activator.CreateInstance(httpChannel, props, null, soapInstance);
 
ChannelServices.RegisterChannel(channelInstance, false);

b) added

Code:
using System.Reflection
using System.Windows.Forms

To the start of the journal.

Which brings me to:

3) This attempted solution keeps throwing a ThreadAbortException. As best as I can narrow it down, the problem is with line 21 in the above snippet. But this type of exception isn't giving me much in the way of a solution to the problem, and it was a bit of a process just to narrow down exactly where the exception was being thrown.

I am absolutely out of my depth at this point. This exception has me stumped, with no relief coming from google.

Hopefully someone here actually understands anything involved with this and can either explain to me what's going on, or just outright solve the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor