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

Problem calling WCF Service from within AutoCAD 2012

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
ognyandim
1196 Views, 8 Replies

Problem calling WCF Service from within AutoCAD 2012

Hello everybody!

I am experiencing a strange problem and I suppose it is because of some technical detail that I dont currently know.

I have done the first chapter from Windows Communication Foundation 4 Step by Step.

I have built myself a simple service and separete console client that talks with the service and it goes pretty well.

I have made absolutley the same client inside AutoCAD 2012 x64 and tried to call the service and I receive the following error provided on screenshot.

I have provided both codes for you to see. Can you explain the problem? If you provide me a link to something I will be greatful.

Tags (1)
8 REPLIES 8
Message 2 of 9
ognyandim
in reply to: ognyandim

http://through-the-interface.typepad.com/through_the_interface/2008/01/turning-autocad.html - Kean implemented a thing that calls outside in another way, but that is not exactly what I am looking for.

Message 3 of 9
ognyandim
in reply to: ognyandim

I am going to answer it here myself.

We need the app.config loaded. When we have Conosle Client App the config is loaded, but when we make a library client ( .dll that we have to NETLOAD ) it is not loaded anywhere and therefore the config is unavailible.

I have solved my problem by pasting the configuration in acad.exe.config. That way my WCF client config is availible the to .dll which is hosted inside AutoCAD.

 

Here I have found a pretty good intro video for WCF hosted inside AutoCAD. ( Mine was outside of AutoCAD ) :

http://au.autodesk.com/?nd=event_class&jid=610987&session_id=7182

Message 4 of 9
BKSpurgeon
in reply to: ognyandim

We need the app.config loaded. When we have Conosle Client App the config is loaded, but when we make a library client ( .dll that we have to NETLOAD ) it is not loaded anywhere and therefore the config is unavailible.

I have solved my problem by pasting the configuration in acad.exe.config. That way my WCF client config is availible the to .dll which is hosted inside AutoCAD.

 

Is it possible to solve the problem by using a new configuration file rather than using the acad.exe.config file? Do you have any ideas on this - it would be very much appreciated by my and future readers as well.

 

rgds

BK

Message 5 of 9
ognyandim
in reply to: BKSpurgeon

Here is an example of external config files but it will involve editing acad.config a bit.

Today a will not bother with WCF - I am using Azure Service Bus + Storage + Worker Role and there isno need for such configs - pure crypted xml will suffice.

 

My original question was 3 years ago and I suppose WCF has developed new capabilities and this case is solvable now. Back then in 2012 I did not know how to properly use Reflector / dotPeek to inpect the codes possible configuration resolution paths.

 

If you tell me which version of wcf you are using I will investigate it and write you a sample.

Message 6 of 9
ognyandim
in reply to: BKSpurgeon

You can try asking this question in StackOverflow too and TheSwamp

Message 7 of 9
BKSpurgeon
in reply to: ognyandim

Hi thank you for the link.

 

Perhaps I should explain the problem at hand:

 

The problem at hand is to read different tag values from a particular block in the modelspace, and to apply different configuration settings according to those tag values. I am not using WCF at all per se.

 

In other words, ff the block says:

  • "Sand" in a particular tag value, then I want all the lines drawn in my program to be yellow. 
  • "Grass" then i want all the lines drawn in my program to be green.
  • "Concrete" then I want all the lines drawn in my program to be grey.

But I don't want to hardcode the values: it needs to be in a config file, so that if I decide to add another surface type: e.g. "tarmac" then I can do so by adding it to the config file and not having to worry about recompiling.

 

so I need a config file which says basically:

 

Sand type ----> line color = yellow

grass ----> line color = yellow

Concrete ----> line colour = grey

 

And then in my autocad program I need to read the tag value from the block (and to find out whether I am dealing with sand or greass or concrete) and apply the correct settings accordingly:

 

if BlockTagValue == sand then -----> apply the sand settings from the config file.

 

That's really as far as I've worked it out. Unsure about implementation so any pointers will be valuable. I don't think that this sort of thing has been clearly answered on the forum so I intended to post my full answer and results for the benefit of future readers, as soon as I find out. Any info you provide will be appreciated and assist in this process.

 

rgds

 

BK

 

 

 

 

 

Message 8 of 9
fieldguy
in reply to: BKSpurgeon

It seems like this belongs in a different thread.  It's hard to determine what exactly you are looking for.

 

To use an App.Config file, you can do something like this.

System.Configuration.Configuration config = null;
string exeConfigPath = this.GetType().Assembly.Location;

try
{
config = System.Configuration.ConfigurationManager.OpenExeConfiguration(exeConfigPath);
}

 

Then when you want to find the value of a key:

 System.Configuration.KeyValueConfigurationElement element = config.AppSettings.Settings[key];
if (element != null)
{
string value = element.Value;
if (!string.IsNullOrEmpty(value))
return value;
}
return string.Empty; 

Message 9 of 9
ognyandim
in reply to: BKSpurgeon

That is simple - just put your key-value pairs in csv and read them/write them.

For the problem : Do you want to change the colors of everything in the block tagged with "X" or you want to change the color of the entities which are in the block AND in particular layer? Because sometimes there are several things inside a block and you need to distinguish between thisngs in different different layers inside one block. I will paste you some code with the config itself tonight.

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