【问题标题】:Why not find the assembly为什么找不到组件
【发布时间】:2012-06-12 11:47:22
【问题描述】:

我有两个项目 Portfolio.Domain 和 Portfolio.Web。 我在 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>

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-3 entity-framework-4.1 ef-code-first


    【解决方案1】:

    您的完全限定程序集名称。像这样的:

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

    获取程序集全名的最简单方法之一是在 ILSpy/Reflector 中打开它。获取类型的程序集限定名称的其他方法是执行以下片段

    typeof(Context.DataContext).AssemblyQualifiedName 
    

    【讨论】:

    • 如何获取程序集全名?
    猜你喜欢
    • 2020-07-10
    • 2011-12-14
    • 2021-05-16
    • 2010-10-12
    • 1970-01-01
    • 1970-01-01
    • 2022-11-29
    • 2023-03-31
    • 2021-12-09
    相关资源
    最近更新 更多