Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
Hello.

I wasn't able to find much help on StructureMap's website, so I'm hoping perhaps I can find some help here. I think I have just a small bug in my StructureMap code, but I'm not sure where....

I'm trying to install structuremap into my 1st website but I'm unable to successfully reference classes set within structuremap. I have 2 projects: a c# class library (MyCompany.MySite.Core) & my website (MyCompany.MySite.Web). My structuremap.config contains a reference to a class I created called "IRedirector". The config file looks like the following:
<br /><?xml version="1.0" encoding="utf-8" ?><br /><StructureMap><br />  <Assembly Name="MyCompany.MySite.Core" /><br />  <Assembly Name="MyCompany.MySite.Web" /><br />  <PluginFamily Assembly="MyCompany.MySite.Core" Type="MyCompany.MySite.Core.Impl.IRedirector" DefaultKey="Default"/><br /></StructureMap><br />


My IRedirector class looks like this:
<br />namespace MyCompany.MySite.Core.Impl<br />{<br />    [PluginFamily("Default")]<br />    public interface IRedirector<br />    {<br />        /// <summary><br />        ///     Sends the user to the home page.<br />        /// </summary><br />        void GoToHomePage();<br /><br />        /// <summary><br />        ///     Sends the user to the error page.<br />        /// </summary><br />        void GoToErrorPage();<br />    }<br />}<br />


Now, as I understood it, I should be able to reference this class in my website by referencing MyCompany.MySite.Core, but I get an error. Instead, my website wants MyCompany.MySite.Core.Impl.
For example, the following is incorrect:
<br />using MyCompany.MySite.Core;<br /><br />namespace MyCompany.MySite.Web<br />{<br />     public class Global : System.Web.HttpApplication<br />     {<br />          protected void Application_Error(object sender, EventArgs e)<br />        {<br />            IRedirector redir = ObjectFactory.GetInstance<IRedirector>();<br />            redir.GoToErrorPage();<br />        }<br />     }<br />}<br />


In that example, the line beginning with "IRedirector" will throw an error, unless I add a reference to "using MyCompany.MySite.Core.Impl;"

I want to reference it using only "MyCompany.MySite.Core". Any idea what I'm doing wrong?

Thanks.
Posted

1 solution

Goalie35 wrote:
I have 2 projects: a c# class library (MyCompany.MySite.Core) & my website (MyCompany.MySite.Web).


Goalie35 wrote:
my website wants MyCompany.MySite.Core.Impl.


Goalie35 wrote:
unless I add a reference to "using MyCompany.MySite.Core.Impl;"


All are contradictory statements. You said you have only two projects, so where does the MyCompany.MySite.Core.Impl came from? If MyCompany.MySite.Core.Impl is just a name space inside project MyCompany.MySite.Core, you need to add proper namespace includes at the place where you use it.
using MyCompany.MySite.Core;<br />using MyCompany.MySite.Core.Impl;<br /><br />namespace MyCompany.MySite.Web<br />{<br />     public class Global : System.Web.HttpApplication<br />     {<br />        /* your code goes here */<br />     }<br />}
:)

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900