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 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

Related Questions

I am facing a really weird error,while trying to insert into a table called
I constantly have some situations in which I have to retry some operations if
Should I constantly have a session open in my web site with user accounts,
We currently facing some stability issues with our develop web application product. This product
I have a fragment which pulls down data from a webservice and displays this
i'm trying to run Redmine using rubyEE, but I am constantly facing some action_controller
I am facing quite strange problem. Application ~80.Mb Testing on simulator using Allocations Instrument,
I'm constantly hearing about person y had performance issue x which they solved through
Constantly monitor a http request which if returns code 200 then no action is
Sorry for constantly re-editing my question but looks like this is the only way

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.