I am using some webservices in my Inventor Addin (as previous in Office Addin), and I am using App.config to define webservices path.
The Inventor addin is not assuming the webservices paths defined in App.config.
In Office addin worked perfect.
What could be?
Thanks & Regards,
Rui
Solved! Go to Solution.
Solved by rjay75. Go to Solution.
I'm not an expert in Office add-ins, but a simple way I'm solving that with Inventor add-ins is to have an addin.config file located in the same directory than my add-in dll, then I load the config at runtime.
Here is an example where I instanciate a WPF service from my add-in:
FileInfo fi = new FileInfo( System.Reflection.Assembly.GetExecutingAssembly().Location); string configPath = fi.DirectoryName + "\\" + "addin.config"; Configuration config = ConfigurationManager.OpenMappedExeConfiguration( new ExeConfigurationFileMap { ExeConfigFilename = configPath }, ConfigurationUserLevel.None); ConfigurationChannelFactory<IAdnViewerConsoleSrv> channelFactory = new ConfigurationChannelFactory<IAdnViewerConsoleSrv>( "WCFClientEndpoint", config, null); _serviceClient = channelFactory.CreateChannel();
Hope that helps,
Philippe.
I have an “App.config” in my project that when compiled generates a similar “ApplicationAddin.dll.config” file located in the same directory than my add-in dll.
In Office addin application (and for all other .Net applications) automatically load from this config file.
Thanks & Regards,
Rui
It's different in Inventor, you will most likely need to "manually" load your config file as I illustrated above...
Regards,
Philippe.
What is the "IAdnViewerConsoleSrv" and the "_serviceClient".
I do not call any webservice directly from my Inventor addin. In Inventor Addin I created some .Net Dlls with common code and webservices are called from that Dlls.
I created these Dlls because the code inside is used from all addins, Office, Inventor, ...
Those are my WCF interface and client, I use them to perfom the web service calls. It's very unclear what you are doing, so please provide further information... What are you using to call the web services? Most likely you will need a way to initialize your service client from providing a path to the config file. If you cannot do that, you may need to review your approach.
Regards,
Philippe.
I have some Dlls and that Dlls make some calls of webservices. Each of that that dll have an App.config where it is defined the path for the webservices.
Sample code of the App.config:
<eGrouWS.Properties.Settings> <setting name="eGrouWS_WSDocument_ws_Document" serializeAs="String"> <value>http://localhost:4451/ws_Document.asmx</value> </setting> </eGrouWS.Properties.Settings>
These dlls are added to my addins, and in each addin I have an App.config where I redefine the url for the webservices called in dlls. For example:
<eGrouWS.Properties.Settings> <setting name="eGrouWS_WSDocument_ws_Document" serializeAs="String"> <value>http://roliveira/ws_Document.asmx</value> </setting> </eGrouWS.Properties.Settings>
This works perfect for the Office addins and for all other .Net projects that use these same dlls.
Here a sample code of calling a webservice in dlls:
ws_Document iws_docm = new ws_Document(); ids_docm = iws_docm.m_GetDocument(is_codValtId, is_sessionKey, is_codDocmId);
Sorry I don't have experience with ASMX web services, this is the "old" way to deal with web services, if you have the opportunity you should migrate to WCF.
The samples I provided are based on WCF and I don't have any issue to use my services from an Inventor add-in.
I think the issue might be your services are looking for the config file in the exe folder, which is most likely different from the addin dll folder, did you try to place the config file in the Inventor.exe folder?
Regards,
Philippe.
This has to do with the mechanisms that are loading the dll and activating the add ins. Inventor most likely is not loading it's addin's in the exact same fashion Office loads it's addins. You basically need a way to point your addin to the correct configuration file. You can explictly load the correct configuration file and use the value to initialize the webservice. But it depends on how your dll that uses the webservice looks up the value from the configuration.
See this link from Stack Overflow that details this problem and has a solution. This may work but may have unknown side effects.
I think the best method for your case since you will be using the DLL from multiple types of addins is to have the dll explictly load its own config file or add a way to pass the needed value to the dll when you use it.