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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:50:36+00:00 2026-05-23T09:50:36+00:00

is there any problem with this kinda registration via structure map?? static public class

  • 0

is there any problem with this kinda registration via structure map??

 static public class ContainerBootstrapper
{
    static public void BootstrapDefaultContainer(bool test = false)
    {
      StructureMap.ObjectFactory.Initialize(x =>
         {
           x.Scan(p =>
             {
                 p.AssemblyContainingType<IPropertyType>();
                 p.AddAllTypesOf<IPropertyType>();
                 //                     p.AddAllTypesOf<IPropertyType>().NameBy(c => c.Name);
             });

        });
  }





 public interface IPropertyType : IIdentityObject, IPriority
{
    string PropertyName { get; set; }

    ObjectType ObjectType { get; }

    string DisplayName { get; set; }

    IEntityType EntityType { get; set; }

    IList<IPropertyRuleObject> RuleObjects { get; set; }

    void AddRuleObject(IPropertyRuleObject ruleObject);

}



 public abstract class PropertyTypeBase : PersistentObject, IPropertyType
{
    public PropertyTypeBase()
    {

    }

    public PropertyTypeBase(string propertyName, string displayName)
    {
        PropertyName = propertyName;
        DisplayName = displayName;
    }

   ....

 }



public class StringType : PropertyTypeBase
{
    private ObjectType _objectType;

    public StringType()
    {
        _objectType = new ObjectType(typeof(string));
    }

    public StringType(string propertyName, string displayName)
        : base()
    {
        PropertyName = propertyName;
        DisplayName = displayName;
    }

    public override ObjectType ObjectType
    {
        get { return _objectType; }
    }
}

when ContainerBootstrapper.BootstrapDefaultContainer(); execute I see this line of error:

StructureMap Exception Code:  200

Could not find an Instance named “StringType” for PluginType Azarakhsh.Domain.Core.AdaptiveObjectModel.Interface.IPropertyType

the calling code:

 public IPropertyType GetPropertyType(IIdentityObject identityObject, string name)
    {
        string[] Properties = name.Split('.');

        object Result = identityObject;

        foreach (var Property in Properties)
            Result = Result.GetType().GetProperty(Property).PropertyType.Name;

        IPropertyType propertyType = StructureMap.ObjectFactory.GetNamedInstance<IPropertyType>  (Result + "Type");
        if (propertyType==null)
            throw new Exception("Property type not found");

        return propertyType;
    }

what is the problem?

  • 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-23T09:50:36+00:00Added an answer on May 23, 2026 at 9:50 am

    You are trying to get a named instance, but from what I can see of the code you have provided, you dont name your instances. The line of code that name your instances is commented out.

    But even if you would just use the ObjectFactory.GetInstance<IPropertyType>(); here, you would have got an error because structuremap dont know what constructor to use. There are several solutions to theis problem.

    1. Change your design so you only have one constructor
    2. Mark your default constructor with the [DefaultConstructor] attribute, then it will work.
    3. You can register it with objectFactory manually with something like this:

      x.For().Use().Ctor(“propertyName”).Is(“someValue”).Ctor(“displayName”).Is(“someValue”);

    4. You can write a custom registrationconvention as described here

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

Sidebar

Related Questions

Is there any good practice for this? I wish I could solve the problem
is there any problem to install different oracle 11g versions. I mean if I
Is there any solution to overcome case-sensitive problem for contains method. I have code
The problem it's easy. Is there any function in JAVA to compare two Strings
Are there any problems converting a Visual Foxpro 6 application to Visual Foxpro 9;
Hopefully the answer is no, but are there any problems with using Request.Params instead
Are there any inherent problems with calling an ole object from tsql? I have
Are there any concurrency problems with one thread reading from one index of an
Would there be any problems calling an HTTPS page (e.g. a credit card authorisation
Is there any way to check whether a file is locked without using a

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.