0

シンプルなプロジェクト、新鮮な MVC4 カミソリ Web ページ、新しい空の mysql データベース。この例外を取得する:

System.Reflection.TargetInvocationException was unhandled by user code
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Threading.LazyInitializer.LazyHelpers`1.ActivatorFactorySelector()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   at System.Threading.LazyInitializer.EnsureInitialized[T](T& target, Boolean& initialized, Object& syncLock)
   at KHSWebsite.Filters.InitializeSimpleMembershipAttribute.OnActionExecuting(ActionExecutingContext filterContext) in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 21
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func`1 nextInChain)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<>c__DisplayClass3b.<BeginInvokeActionMethodWithFilters>b__35()
   at  System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func`1 nextInChain)
InnerException: System.InvalidOperationException
   Message=The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588
   Source=KHSWebsite
   StackTrace:
        at  KHSWebsite.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 45
   InnerException: System.InvalidOperationException
        Message=The connection string 'DefaultConnection' in the application's configuration file does not contain the required providerName attribute."
        Source=EntityFramework
        StackTrace:
             at  System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
             at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
             at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
             at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
             at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
             at System.Data.Entity.Internal.InternalContext.CreateObjectContextForDdlOps()
             at System.Data.Entity.Database.Exists()
             at  KHSWebsite.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\users\alex\documents\visual studio 2010\Projects\KHSWebsite\KHSWebsite\Filters\InitializeSimpleMembershipAttribute.cs:line 34
         InnerException: 

これが私のweb.configです:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=localhost;Initial     Catalog=KHS;Integrated       Security=SSPI;"/>
  </connectionStrings>
  <system.web>
    <authentication mode="Forms">
       <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH"/>
    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
       <providers>
         <clear/>
         <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DefaultConnection" applicationName="KHS" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed"/>
       </providers>
    </membership>
    <compilation debug="true"/>
  </system.web>
</configuration>

これは、http://msdn.microsoft.com/en-us/library/6e9y4s5t( v=vs.100 ).aspxから取得および変更されたものです。

何かご意見は?ありがとう

4

1 に答える 1

0

接続文字列のプロバイダー属性が欠落していると表示されます。そのプロバイダーを確認しましたか。

このようなものが接続文字列になるはずです

<add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Initial Catalog=ApplicationServicesDB;Integrated Security=True;MultipleActiveResultSets=True"
         providerName="MySql.Data.MySqlClient"/>

また、ファイルの に mysql を登録する必要がsystem.dataありweb.configます。

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
</system.data>
于 2013-05-18T17:51:28.160 に答える