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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:52:46+00:00 2026-05-13T10:52:46+00:00

I am constantly facing this error while testing. I cannot even create an instance

  • 0

I am constantly facing this error while testing. I cannot even create an instance of IRoleRepository which should return RoleRepository.

Here is the error:

TestCase ‘EStudy.Repository.Tests.when_fetching_instance_of_role_repository_using_structuremap.should_fetch_successfully’
failed: StructureMap.StructureMapException : StructureMap Exception Code: 202
No Default Instance defined for PluginFamily EStudy.Domain.Model.Model.EStudyModelDataContext, EStudy.Domain.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
at StructureMap.BuildSession.<.ctor>b__0(Type t)
at StructureMap.Util.Cache2.get_Item(KEY key)
at StructureMap.BuildSession.CreateInstance(Type pluginType)
at StructureMap.Pipeline.DefaultInstance.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.ConfiguredInstanceBase
1.getChild(String propertyName, Type pluginType, BuildSession buildSession)
at StructureMap.Pipeline.ConfiguredInstanceBase1.StructureMap.Pipeline.IConfiguredInstance.GetChild(String propertyName, Type pluginType, BuildSession buildSession)
at EStudyDomainModelRepositoriesRoleRepositoryInstanceBuilder4c713d65fe464f4792cd90352224a54b.BuildInstance(IConfiguredInstance , BuildSession )
at StructureMap.Pipeline.ConfiguredInstanceBase
1.StructureMap.Pipeline.IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
at StructureMap.Pipeline.ConfiguredInstanceBase1.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.<.ctor>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.GetInstanceT
at StructureMap.ObjectFactory.GetInstancePLUGINTYPE
C:\Projects\EStudyVS2008\EStudySoltution\EStudy.Repository.Tests\Test_StructureMapConfiguration.cs(41,0): at EStudy.Repository.Tests.when_fetching_instance_of_role_repository_using_structuremap.should_fetch_successfully()

 [TestFixture]
    public class when_fetching_instance_of_estudy_data_context_using_structuremap : BaseTest
    {

        [Test]
        public void should_fetch_successfully()
        {
           Assert.IsNotNull(ObjectFactory.GetInstance<EStudyModelDataContext>());
        }
    }

BaseTest: 

 public class BaseTest
    {
        private TransactionScope _scope;

        static BaseTest()
        {
            EStudy.Domain.Model.Configuration.StructureMapConfiguration.Configure(); 
        }

And here is the StructureMapConfiguration.Configure method; 

 public class StructureMapConfiguration
    {
        public static void Configure()
        { 
            ObjectFactory.Initialize(InitializeStructureMap);

            ObjectFactory.Initialize(j =>
            {
                j.ForRequestedType<EStudyModelDataContext>().TheDefault.Is.OfConcreteType<EStudyModelDataContext>().WithCtorArg("connection")
                    .EqualTo(ConfigurationManager.ConnectionStrings["EStudyTestDatabaseEntities"].ConnectionString);

            });
        }

        public static void InitializeStructureMap(IInitializationExpression x)
        {
            x.Scan(y =>
                       {
                           y.Assembly("EStudySoltution.EStudy.Domain.Model");
                           y.With<DefaultConventionScanner>();
                       }

                );





        }
  • 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-13T10:52:46+00:00Added an answer on May 13, 2026 at 10:52 am

    You should not be calling Initialize() more than once. From the docs:

    “Any successive calls to Initialize() will effectively wipe out any existing configuration and effectively restart the Container.”

    If you want to add additional configuration to an existing container, use Objectfactory.Configure().

    I’m not sure that explains why you are getting the error you see for EStudyModelDataContext, but it definitely looks at least one problem with what you posted.

    You can also see what you do and don’t have configured properly by calling container.WhatDoIHave() (which outputs a string you can send to the console).

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

Sidebar

Ask A Question

Stats

  • Questions 340k
  • Answers 341k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is some native support for what you want to… May 14, 2026 at 4:51 am
  • Editorial Team
    Editorial Team added an answer Yes and no. You can access it with a "super… May 14, 2026 at 4:51 am
  • Editorial Team
    Editorial Team added an answer * matches in a greedy fashion, *? matches in a… May 14, 2026 at 4:51 am

Related Questions

Leading on from my previous questions I am going to try and clarify one
I'm working on an app which takes in a raw binary message (very simple,
I have not marked this question Answered yet. The current accepted answer got accepted
I have Apache running on a public-facing Debian server, and am a bit worried
I am facing an application that uses hashing, but I cannot still figure out

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.