I have an Excel VSTO workbook project. The excel workbook uses windows service WCF connection. This connection is defined in another class library that is referenced in the VSTO workbook template project.
Another project launches this workbook using following code:
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wb = excel.Workbooks.Open(filepath);
excel.Visible = true;
Then excel creates a windows service proxy class in Sheet_Activate event handler by simply creating new object:
MyServiceClient service = new MyServiceClient();
And then I get an exception:
“Could not find default endpoint element that references contract ‘MyService.IMyService’ in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.”.
But I get this exception on one PC only. On few other PCs this application works fine. And the app configuration is the same on all PCs: the excel version is the same, the windows service is deployed the same, the app.config is the same. What could be the reason of my application failing with this error?
Maybe it really can’t find the config file, as said in error message? How do I check it? What else can I do to solve this problem?
It appears that my workbook looks for configuration in excel.exe.config file on the machine where the workbook doesn’t work. On machines where workbook works “my project”.dll.config is looked for and is found. I’ve copied the correct config file to excel application directory as “excel.exe.config” and everything works fine now.