c# - Cyclic references and DI -


i have wcf project named service1 has interface iactions

public interface iactions {     int dosomething(int param); }  public class service1 : iservice1 {     private iactions actions;      public service1(iactions actions)     {         this.actions = actions;     }      public myaction(int p)     {         return this.actions.dosomething(p);     }  } 

then have other project implements iactions interface, has reference service1

public class someclass : iactions {     public int dosomething(int param)     {         return param*param;     } } 

now want implement di ninject, , doing bindings

public class ninjectbindings : ninjectmodule {     public override void load()     {         bind<iactions>().to<someclass>();         bind<servicehost>().to<ninjectservicehost>();     }  } 

this isnt possible because introduces cyclic references. doing wrong? know should have design flaws, appreciate may show them me.

you don't have cyclic reference of classes in example. have cyclic assembly references. introduce contract assembly contains interfaces shared between them , you'll fine.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -