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 400103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:54:44+00:00 2026-05-12T16:54:44+00:00

is it possible to get this stuff working(some way to force Objectfactory create instances

  • 0

is it possible to get this stuff working(some way to force Objectfactory create instances like Activator)

in the below example everything is placed in a sigle assembly

public interface IUnitOfWorkFactory
{
    IUnitOfWork Create();
}

internal class NHUnitOfWorkFactory : IUnitOfWorkFactory
{
    public IUnitOfWork Create()
    {
        ////  do needed stuff
    }
}

bootstrapping :

ObjectFactory.Configure(x =>
{
    x.ForRequesedType<IUnitOfWorkFactory>.TheDefaultIsConcreteType<NHUnitOfWorkFactory>();
}); 

usage:

IUnitOfWorkFactory factory = ObjectFactory.GetInstance<IUnitOfWorkFactory>();

My result:

Porktal.Core.Tests.UnitOfWorkTests.Can_Start_Unit_of_Work : StructureMap.StructureMapException : StructureMap Exception Code:  207
Internal exception while creating Instance 'Porktal.Core.Data.NH.NHUnitOfWorkFactory, Porktal.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' of PluginType Porktal.Core.Data.IUnitOfWorkFactory.  Check the inner exception for more details.
---- System.MethodAccessException : Porktal.Core.Data.NH.NHUnitOfWorkFactory..ctor()
Stack Trace:
   at StructureMap.Pipeline.ConfiguredInstanceBase`1.StructureMap.Pipeline.IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
   at StructureMap.Pipeline.ConfiguredInstanceBase`1.build(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.BuildPolicy.Build(BuildSession buildSession, Type pluginType, Instance instance)
   at StructureMap.InstanceFactory.Build(BuildSession session, Instance instance)
   at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
   at StructureMap.BuildSession.b__0(Type t)
   at StructureMap.Util.Cache`2.get_Item(KEY key)
   at StructureMap.BuildSession.CreateInstance(Type pluginType)
   at StructureMap.Container.GetInstance(Type pluginType)
   at StructureMap.Container.GetInstance[T]()
   at StructureMap.ObjectFactory.GetInstance[PLUGINTYPE]()
   at Porktal.Core.Bootstraper.Bootstrap() in D:\Porktal\Porktal.Core\Bootstraper.cs:line 20
   at Porktal.Core.Tests.UnitOfWorkTests.Can_Start_Unit_of_Work() in D:\Porktal\Porktal.Core.Tests\UnitOfWorkTests.cs:line 11
----- Inner Stack Trace -----
   at PorktalCoreDataNHNHUnitOfWorkFactoryInstanceBuilder44203c8113d44053be045df4db28c3dc.BuildInstance(IConfiguredInstance , BuildSession )
   at StructureMap.Pipeline.ConfiguredInstanceBase`1.StructureMap.Pipeline.IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)

  • 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-12T16:54:44+00:00Added an answer on May 12, 2026 at 4:54 pm

    You have 2 options. You can make NHUnitOfWorkFactory public (preferred).

    Or you can put the code that constructs your internal class in your assembly (where it has access to internal members) in the form of a lambda , and pass it to StructureMap:

    ObjectFactory.Configure(x => {
      x.ForRequestedType<IUnitOfWorkFactory>()
       .TheDefault.Is.ConstructedBy(() => new NHUnitOfWorkFactory())
    });
    

    The equivalent with newer versions of StructureMap is:

    ObjectFactory.Configure(x => {
      x.For<IUnitOfWorkFactory>().Use(() => new NHUnitOfWorkFactory())
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sortable list like this one: http://jqueryui.com/demos/sortable Is it possible to get
I'm working on some Django-code that has a model like this: class Status(models.Model): code
We can easily alert anything in java script. Is it possible to get this
I am wondering if its possible to get $(this).scrollTop() value after an anchor jump.
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of
Is it possible to get help with this fiddle: http://jsfiddle.net/aLCfb/ . I am trying
Anyone know how to get this to work if it's possible? class Foo def
Possible Duplicate: Get a list of dates between two dates This is my sql:
Is it possible to get the value from a JavaScript variable and use this
According to this article , it's possible to get multiline XML comments -- instead

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.