1

I found this How to export C# methods? answer which solved my problem partially i.e. I used this https://sites.google.com/site/robertgiesecke/Home/uploads#TOC-Version-1.1.3 (as suggested by SLaks) template to call my dll in native C++ code.

I am facing two problems while using this Unmanaged Exports template, I can't say for sure if they are being caused due to this template or do they have to do something with Interoperability of C# and C++.

The first problem was this, when i tried to call a function of a third party .NET DLL from my .NET DLL which was in turn being called by Native C++ code it gave an error:

Native C++ --> MyDLL (.NET DLL) --> ThirdParty.NET DLL

I found the solution here Problem in using a .net dll from c++ dll via c++/cli layer I had to sign my DLL.

Now the second problem is:

When I try to do the samething with WCF Service i.e. Adding a reference of WCF Service in MyDLL initalizing it and calling functions, the program breaks at C++ end

Native C++ --> MyDLL (.NET DLL) --> WCF Service Reference

I even tried doing this and it worked till AnotherDLL (which was signed) but broke at WCF

Native C++ --> MyDLL (.NET DLL) --> AnotherDLL (.NET DLL) --> WCF Service Reference

What I have found out till now is that whenever I try to initalize anything class from the WCF Service (Service Client, DataContract class it breaks).

If anyone has any idea, I would really appricate it and what else would be the best approach for this problem.

Thanks

Community
  • 1
  • 1
adnangohar
  • 167
  • 1
  • 3
  • 11
  • This could be when it looks for the configuration file. Have you tried creating the WCF client only through code in your .NET code? – Graymatter Oct 11 '11 at 12:57
  • Thanks tried hosting my service on a console application and connecting to it and it worked, but I am still confused why does it break when I add a reference using "Add Service Reference" in Visual Studio 2010. – adnangohar Oct 11 '11 at 15:40
  • Solved it, thanks Graymatter :) ........ the problem was that my DLL was not reading the app.config file so I had to set the App config path to the right config file .... just needed to add this line of code -- AppDomain.CurrentDomain.SetData ("APP_CONFIG_FILE", "path to config file"); – adnangohar Oct 12 '11 at 07:16

0 Answers0