80018

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily

I am Using Entity Framework 4.0 calling the below mentioned code from asp.net. I have a address table in which I need to insert some data. my code is :

IRepository<Address> addressRepository; int addressHOCODE = 0; try { **addressRepository = ObjectFactory.GetInstance<IRepository<Address>>();** addressRepository.Add(address); addressRepository.SaveChanges(); addressHOCODE = address.HOCODE; } catch ...

At the addressRepository = ObjectFactory.GetInstance<IRepository<Address>>(); line, we're getting the following error.

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily Domain.IRepository`1[[Data.Address, DataAccessLayerNew, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], DataAccessLayerNew, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Answer1:

Looks like you worked this out for yourself, but to help others who might come across this page, I'd expect to see something like this in the Global.asax.cs file:

using System; namespace Host { public class Global : System.Web.HttpApplication { protected void Application_Start (object sender, EventArgs e) { ObjectFactory.Configure(config => { config.For<IRepository>().Use<ConcreteRepository>(); }); } } }

Recommend

  • Detecting direct instantiation with nDepend
  • Suddenly my spring.xml won't instantiate my classes and Error Exception occurs
  • Minimal Repository implementation using Entity Framework
  • Search through Tab Control for specific Tab Item based on a String value
  • ViewModel properties stay null on HttpPost
  • My “Create” View in my “Index” View, is it possible?
  • Adding object to database using table-per-type inheritance in Mvc 4
  • Why have a private constructor [duplicate]
  • Populatate the spinner from Firebase database
  • Changing Entity's State in Entity Framework 4.1
  • LESS CSS how to modify parent property in mixin
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • Why does it draw lines in the wrong place?
  • Prevent Tomcat from caching request during starup
  • Find Previous month name using Calender or any classes that in java
  • UIAlertController button function not working
  • Filter strings with regex before casting to numeric
  • Center align outputs in ipython notebook
  • Diff between two dataframes in pandas
  • Parse a date string in a specific locale (not timezone!)
  • How to get Eclipse Oxygen to run on Java 9
  • Converting a WriteableBitmap image ToArray in UWP
  • Chrome doesn't support silverlight anymore? How to solve this?
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Syntax for setting draggablecursor property in google maps api
  • Paperclip, set path outside of rails root folder
  • Why value captured by reference in lambda is broken? [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Spray.io: When (not) to use non-blocking route handling?
  • Modifying destination and filename of gulp-svg-sprite
  • javascript inside java/jsp code
  • GridView Sorting works once only
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Sorting a 2D array using the second column C++
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal