- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a problem with implementing WCF in Autocad P&ID 2014. I've downloaded the trial version of P&ID 2014 to run some test with it. I want to talk to the Autcad application with an external windows aplication. With the help of this example, I've managed it to open Autocad with the external applicatoin. I also created some self made Commands by creating .dll files and NETLOAD them into Autocad. All works fine as I expected. After that, I want to use WCF to talk to the Autocad application. I watched the lesson of Paul Schleppy, which is recommanded in this discussion. I get the WCF service working in Autocad and I can send messages to it without any problems. The service is hosted inside autocad.
The only thing is: When I want to talk to the 'CurrentDocument' of Autocad, I get the following error: eNotApplicable. This error occurs for an example, when I want to send something to the editor of the CurrentDocument. But also when I want to open the database of the CurrentDocument. An expert on .NET programming with Autocad tells me this is because I want to use UI dependent functions on a background thread, which are only available on the UI thread. He said I must avoid this kind of functions. But that means I can't do anything with the CurrentDocument?? He also gave another solution. He says I have to store the UI SynchronizationContext at the startup of the host and then use the UI dependent functions with a 'Post' or 'Send'. But that isn't working either, I still get the eNotApplicable error.
He said the problem could be the trial version of Autocad P&ID 2014, because sometimes trail versions acting weird.
Now I'am curious: Do you have other solutions? Or do you have other experiences with WCF and Autocad and how do you work this out? I really want to make this working.
I have attached my Visual Studio solution. It contains three projects. One host, one service and one client (a little Winform app). I use VS2012 on a 64-bit laptop. Befor you build the soluton, make shure you change the IP adress in the 'Form1' class of the client. Once you build the solution, first NETLOAD the host in Autocad and then the service. Then use the following command: "AutoHostAutocadService". Now the service is listening. After that, you can attach youre VS to Autocad and the you can press F5 for debugging. A little winform app will start. Type something in the textbox and click the button. If you have set a breakpoint in the constructor of the 'FindTag' class, this breakpoint will hit. In the constructor, the eNotApplicable is raised by writing a message to the editor.
Please, can anyone help me?
Solved! Go to Solution.