.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remoting in AutoCAD

0 REPLIES 0
Reply
Message 1 of 1
chrnit
221 Views, 0 Replies

Remoting in AutoCAD

Hi.
I've got a problem using remoting with AutoCAD.
I want to implement a kind of server in AutoCAD that enables external processes to get access to AutoCAD functions.

I have a VS-solution with this layout:
AutoCADServer (dll, class implements IExtensibleApplication)
AutoCADWorker (dll, derived from MarshalByObjReg)
Client1 (exe)

I want to implement certain functionality in AutoCADWorker, like opening DWGs, plotting, some other stuff...
The user now starts Client1 and is able to use this functionality exposed by AutoCADWorker.
At least, this is the idea.

To do this, I have this code:


public class AutoCADServer : IExtensionApplication
{
public void Initialize()
{
RemotingConfiguration.Configure(path_to_server_config, false);
}
// Snip some other unrelated stuff
}

public class AutoCADWorker : MarshalByRefObject
{
public void DoSomething()
{
// does something nice in AutoCAD
}
}

public partial class Form1 : Form
{
RemotingConfiguration.Configure(path_to_client_config, false);
AutoCADWorker.AutoCADWorker remoteObject = (AutoCADWorker.AutoCADWorker)Activator.GetObject(typeof(AutoCADWorker.AutoCADWorker), "tcp://localhost:8989/AutoCADServer");
remoteObject.DoSomething();
}


The config files look like this (< replaced by [):
server_config:

[configuration]
[system.runtime.remoting]
[application]
[service]
[wellknown
mode="Singleton"
type="AutoCADWorker.AutoCADWorker, AutoCADWorker"
objectUri="AutoCADServer"
/]
[/service]
[channels]
[channel ref="tcp" port="8989"/]
[/channels]
[/application]
[/system.runtime.remoting]
[/configuration]

client_config:
[configuration]
[system.runtime.remoting]
[application]
[client]
[wellknown
type="AutoCADWorker.AutoCADWorker, AutoCADWorker"
url="tcp://localhost:8989/AutoCADServer"
/]
[/client]
[/application]
[/system.runtime.remoting]
[/configuration]



Now when I try to load the plugin in AutoCAD, calling RemotingConfiguration.Configure raises an exception, complaining about already having registered a channel named "tcp".

Using Process Explorer, I figured that AutoCAD already opens some .NET channels, appearently, there's really another one named "tcp".
My problem is I don't know how I should give the channel a different name, as there's only an attribute "displayName" for the channel-tag in the config,
but according to MS documentation this isn't used by applications but only to display the name in .NET config tools.

Has anyone done this or something similar before and could help me with this?
I need to get this working soon, I already spend some days with this stuff...

Best Regards
Christian Nitschkowski
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost