I’m trying to make my WCF service use DI as shown here however I don’t know how to initialize the IUnityContainer in the //todo section.
I’ve tried (and failed at)
-
Making the variable
IUnityContainer containerpublic and static and setting it within my Azure Webrole.cs however the public static variable is still null. -
Application variables as shown here
How do I make an MVC application running on Azure use DI with WCF?
The most likely cause of this not working is that you are running the project with Windows Azure SDK 1.3.
In 1.3, the WebRole code (Run/OnStart, etc) continues to run in Hostable Web Core and your site/service runs under IIS. They are different processes so whatever you do in the memory of one will not be visible in the other.
You can either delete the “Sites” section of your service defintion (essentially bringing everything to 1 process: hostable web core and no IIS like in SDK 1.2) or perform initialization in your service: e.g. the global.asax