本文介绍了StructureMap异常代码:202否为PluginFamily定义默认实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Entity Framework 4.0,从asp.net调用下面提到的代码。我有一个地址表,我需要插入一些数据。我的代码是:
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 ...
在 addressRepository = ObjectFactory.GetInstance< IRepository< Address>>();
行,我们收到以下错误。
At the addressRepository = ObjectFactory.GetInstance<IRepository<Address>>();
line, we're getting the following error.
推荐答案
看起来你是为自己做的,但是为了帮助那些可能遇到这个页面的人,我期待看到在Global.asax.cs文件中这样的东西:
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>();
});
}
}
}
这篇关于StructureMap异常代码:202否为PluginFamily定义默认实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!