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

  • Home
  • SEARCH
  • 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 7581329
In Process

The Archive Base Latest Questions

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

I am trying to get WCF work with Structuremap. I took most of the

  • 0

I am trying to get WCF work with Structuremap. I took most of the code from Jimmy Bogard’s blog
Integrating StructureMap with WCF

I am reusing all my objects (Domain, NHIBERNATE , Service layer ) that was created for ASP.nET MVC application.I have a separate IoC Library where I bootstrap all regisrties

I have added global.asax and in Application Start Event this is what I have :

var webServiceRegistry = new WebServiceRegistry();
var bootStrapper = new IoC.BootStrapper();
bootStrapper.Start();

WebServiceRegistry is a normal class and in its constructor I have the following:

 var appUser = new AppUser
            {
                Role = userDto.Role,
                Email = userDto.Email,
                Id = userDto.Id,
                CompanyName = dealerDto.Name,
                Name = userDto.Name,
                IsImpersonated = false,
                Impersonater = Guid.Empty
            };
            System.Threading.Thread.CurrentPrincipal = System.Web.HttpContext.Current.User = appUser;
            ObjectFactory.Configure(x => x.For<IAppUser>().Use(appUser));

Everything goes fine – no errors

Things start to fail when my my wcf service class is being instantiated which has a Domainservice object (IDomainServiceObject domainServiceObject) in constructor with 202 error.

The failure is in DomainService Registry where it fails to get default instance of IAppUser

Edit

Initial problem was in that I had error in constructor of StructureMapServiceHost.

Now I dont get any error but I am not getting the instance of IAppUser that I inject. In place of that it creates a new instance of AppUser.

Do anyone have a clue as to why this happens?

I have tried adding HttpContextScope , HybridHttpOrThreadLocalScoped and still same result

I have conformed that at the time all registries are called in bootstrapper IAppUser instance is the once that was provided with values in it (and not created by StructureMap)
In Application Start it does create the whole graph .

As soon as it enters webmethod ILMSUser is a new instance.

Thank you

  • 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-30T18:10:29+00:00Added an answer on May 30, 2026 at 6:10 pm

    Since you want the same object back every time you can use singleton

    this.For<IAppUser>().Singleton().Use(appUser);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to get an image from a wcf rest service like so: [ServiceContract]
I am trying to configure a WCF server\client to work with SSL I get
When trying to get a RESTful WCF service POST to work in ASP.NET we
I'm trying to get IIS6 to work reliably with a WCF service I have
I'm trying to get my head around the addressing of WCF services. We have
I am trying to make an ajax GET request to a WCF web service
I am trying to understand what is WCF, but can't get a visual understanding
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using

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.