Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7187307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:48:59+00:00 2026-05-28T18:48:59+00:00

I am trying to use dependency injection with WCF REST (WebGet) and am having

  • 0

I am trying to use dependency injection with WCF REST (WebGet) and am having trouble understanding where I would use Unity to build my object to host the web service.

I have seen many examples all over the web, but they seem to all be hosting the service in a console app or Windows service.

Currently my config file looks like this:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Services.MyRestService">
        <endpoint address="http://localhost:8732/api" binding="webHttpBinding" contract="Shared.Services.IMyRestService"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Currently the way it works is using the built in WCF service host in Visual Studio. However, I’d like to run this in IIS and use Unity to configure my container. Now I am using “bastard injection” to get the job done, but would like to use Unity to supply the data provider implementation, etc.

My question is, what configuration changes do I need to make to host this in IIS and also where do I configure the container and let IIS know about it.

There are no SVC files as this is a WCF Service Library.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:49:00+00:00Added an answer on May 28, 2026 at 6:49 pm

    The “normal” way to do this would be to implement a custom IInstanceProvider WCF extension point, and add it through configuration. I’ve only done this with regular SOAP endpoints, but I think it would work the same for WebAPI.

    Couple links that might help:

    • IInstanceProvider (MSDN)
    • Extending WCF Using IInstanceProvider
    • IInstanceProvider (MSDN Blog)
    • Integrating Unity with WCF

    The 2nd link covers some of the XML configuration stuff for adding a custom IInstanceProvider to the behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're trying to use Dependency Injection for a WCF Service. The Service has a
I'm trying to use Dependency Injection and Factory class. I've read quite a bit
I'm trying to understand the best way to use Spring (for dependency injection) with
I have been looking for a way to use Unity for Dependency Injection in
Using MVC and trying to use dependency injection for controllers, but when I try
I am trying to use Dependency Injection as much as possible, but I am
I am trying to use NSManagedObjectContext dependency injection as recommended by Marcus Zarra --
I am trying to work out a way to use dependency injection with ASP.NET
Trying to use a guid as a resource id in a rest url but
I am trying to implement Dependency Injection to make my app tester friendly. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.