VAAA
VAAA

Reputation: 15039

Self-Hosted WCF Service for 32 bit dll access

I have a Visual Studio Solution for a Windows Forms application with some Class Libraries that are my Application Modules. My application run under "Any CPU" and can't be changed to "x86" because it uses lots of 64 bit dll references.

I have a Native C++ 32 bit dll that I need to use inside of one of the app modules but it's quite impossible and dont want to use Wrappers, so I have read that the easiest is to use a Self-Hosted WCF Service.

The approach that I was thinking is to create a Console Application (32 bit) project, that will be referencing the Native C++ 32 bit dll, within my solution and that will host the WCF Service, then when the user opens the app module, I will call a Process.Start(the self hosted wcf console app.exe) so my WCF service starts and then from my windows form application I can access the methods, etc.. and then I will be able to use the native 32 bit dll methods.

I think this is known as Out-of Process application.

Does anyone think there is a better way to do this? I really dont like to have to .EXE apps (the main app exe and the self hosted wcf.exe), can I have the self hosted wcf 32 bit project to live inside my main app.exe 64 bit project? if its possible, how can I call it?

Thanks in advance

Upvotes: 2

Views: 1465

Answers (1)

ilansch
ilansch

Reputation: 4878

I did it in my project, we named the projects with _x64 or _x86, you can have both projects in same solution just change the build setting. we named it process isolation.
Make sure of the following:

  • what happens when parent process dies
  • what happens when child process dies
  • when does parent process knows child process is alive - start using the wcf..
  • you need the calls for x86 to be async ? then use the proper async pattern

you can get answers for these from my questions:

Verify Child Process WCF Service started: C# .net 3.5 inter process communication verify the child process has started ok

Close Hosted Process: best way to close hosted process

Project Reference Work-Around: Project reference work-around .net 4.5 and .net 3.5

Upvotes: 2

Related Questions