我正在尝试构建asp.net mvc4应用程序,并且在运行该应用程序时,我在lazyinitializer的语句中收到错误Exception has been thrown by the target of invocation
。请帮忙。提前致谢。我的代码如下
namespace CMMIS.Web.Filters
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute
{
private static SimpleMembershipInitializer _initializer;
private static object _initializerLock = new object();
private static bool _isInitialized;
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Ensure ASP.NET Simple Membership is initialized only once per app start
LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
}
最佳答案
这是因为LazyInitializer在webconfig中被模仿。只需将其删除,代码即可正常运行
关于asp.net - 调用lazyinitializer mvc4的目标已引发异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16331015/