-1

Portfolio.Domain と Portfolio.Web の 2 つのプロジェクトがあります。Portfolio.Web に参照 Portfolio.Domain を追加します。最初にコードを操作する必要があります。しかし、エラーが発生します:

   The type 'Portfolio.Domain.Context, Portfolio.Domain' could not be found. The type name must be an assembly-qualified name.

web.config:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <connectionStrings>
    <add name="DataContext" providerName="System.Data.SqlClient" connectionString="Data Source=USER\SQLEXPRESS;Initial Catalog=Portfolio;Integrated Security=True;Pooling=False;User Instance = False;MultipleActiveResultSets=true" />
  </connectionStrings>

  <appSettings>
    <add key="webpages:Version" value="1.0.0.0" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="DatabaseInitializerForType Portfolio.Domain.Context, Portfolio.Domain" value="Portfolio.Web.Context.DataContextInitializer, Portfolio.Web" />

  </appSettings>
  <system.web>
    <!--Replace your existing membership config with this one-->
    <membership defaultProvider="CodeFirstMembershipProvider">
      <providers>
        <add name="CodeFirstMembershipProvider" type="CodeFirstMembershipSharp.CodeFirstMembershipProvider" connectionStringName="DataContext" />
      </providers>
    </membership>
    <!--Profile provider not supported, extend your code with Code-First-->
    <profile enabled="false">
      <providers>
        <clear />
      </providers>
    </profile>
    <!--Replace your existing roleManager config with this one-->
    <roleManager enabled="true" defaultProvider="CodeFirstRoleProvider">
      <providers>
        <clear />
        <add name="CodeFirstRoleProvider" type="CodeFirstMembershipSharp.CodeFirstRoleProvider" connectionStringName="DataContext" />
      </providers>
    </roleManager>
    <!--compilation-->

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880" />
    </authentication>
    <!--pages-->
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <!--<runtime>-->

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="Data Source=USER\SQLEXPRESS;Initial Catalog=Portfolio;Integrated Security=True;Pooling=False;User Instance = False;MultipleActiveResultSets=true" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>
4

1 に答える 1

1

完全修飾アセンブリ名。このようなもの:

Context.DataContext, Portfolio.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

アセンブリの完全な名前を取得する最も簡単な方法の 1 つは、ILSpy/Reflector で開くことです。タイプのアセンブリ修飾名を取得する他の方法は、次のスニペットを実行することです

typeof(Context.DataContext).AssemblyQualifiedName 
于 2012-06-12T11:49:55.067 に答える