1

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)

  1. Making the variable IUnityContainer container public and static and setting it within my Azure Webrole.cs however the public static variable is still null.

  2. Application variables as shown here

How do I make an MVC application running on Azure use DI with WCF?

Community
  • 1
  • 1
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
  • There are half a dozen links in your "as shown here" can you specify more precisely which implementation did you use? – Andrew Savinykh Mar 16 '11 at 10:43
  • @zespri I used `HttpRuntime.Cache.Insert` as demonstrated in the answer. Do you have any issues in an MVC application with this object? – makerofthings7 Mar 17 '11 at 13:58

1 Answers1

0

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

Eugenio Pace
  • 14,094
  • 1
  • 34
  • 43