2017-09-12 1 views
0

J'ai un problème avec les projets. Chaque fois, je crée un projet qui utilise EntityFramework j'ai ce problème.Impossible de charger le fichier ou l'assemblage 'BookMe' ou l'une de ses dépendances

Il y a trace d'assemblage:

=== Pre-bind state information === 
LOG: DisplayName = BookMe 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: BookMe | Domain ID: 2 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///C:/Users/mscib/Documents/GitHub/BookMe/BookMe.WebUI/ 
LOG: Initial PrivatePath = C:\Users\mscib\Documents\GitHub\BookMe\BookMe.WebUI\bin 
Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Users\mscib\Documents\GitHub\BookMe\BookMe.WebUI\web.config 
LOG: Using host configuration file: C:\Users\mscib\Documents\IISExpress\config\aspnet.config 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/ea956ac0/519f841f/BookMe.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/ea956ac0/519f841f/BookMe/BookMe.DLL. 
LOG: Attempting download of new URL file:///C:/Users/mscib/Documents/GitHub/BookMe/BookMe.WebUI/bin/BookMe.DLL. 
LOG: Attempting download of new URL file:///C:/Users/mscib/Documents/GitHub/BookMe/BookMe.WebUI/bin/BookMe/BookMe.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/ea956ac0/519f841f/BookMe.EXE. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/ea956ac0/519f841f/BookMe/BookMe.EXE. 
LOG: Attempting download of new URL file:///C:/Users/mscib/Documents/GitHub/BookMe/BookMe.WebUI/bin/BookMe.EXE. 
LOG: Attempting download of new URL file:///C:/Users/mscib/Documents/GitHub/BookMe/BookMe.WebUI/bin/BookMe/BookMe.EXE. 

Trace de la pile:

[FileNotFoundException: Could not load file or assembly 'BookMe' or one of its dependencies. Nie można odnaleźć określonego pliku.] 
    System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0 
    System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +95 
    System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +53 
    System.Type.GetType(String typeName, Boolean throwOnError) +43 
    System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage) +46 

[InvalidOperationException: Failed to set database initializer of type 'BookMe.Domain.Concrete.BookMeInitializer, BookMe' for DbContext type 'BookMe.Domain.Concrete.BookMeContext, BookMe' specified in the application configuration. See inner exception for details.] 
    System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage) +314 
    System.Data.Entity.Internal.<>c__DisplayClass6.<TryGetInitializerFromEntityFrameworkSection>b__1(ContextElement e) +255 
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +223 
    System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +115 
    System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type contextType) +23 
    System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name) +511 
    System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +84 
    System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key) +175 
    System.Linq.WhereSelectArrayIterator`2.MoveNext() +75 
    System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +115 
    System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key) +38 
    System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +169 
    System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +174 
    System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +269 
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +38 
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +77 
    System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +21 
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +83 
    ASP._Page_Views_Test_Index_cshtml.Execute() in C:\Users\mscib\Documents\GitHub\BookMe\BookMe.WebUI\Views\Test\Index.cshtml:8 
    System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252 
    System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148 
    System.Web.WebPages.StartPage.ExecutePageHierarchy() +88 
    System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107 
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +88 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +831 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81 
    System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65 
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36 
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +607 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134 

J'ai essayé tons de solutions. J'ai changé prémision à Temporary Asp Net, aussi je l'ai supprimé. J'ai vérifié les assemblages. Je ne peux pas comprendre ce que je peux faire.

Merci pour l'aide, msciborski.

EDIT: Mes solutions contient 3 projets: Domaine, WebUI, UnitTests. WebUI est défini comme projet de démarrage et il est 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=301880 
    --> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <connectionStrings> 
    <add name="BookMeDb" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=BookMe1;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="webpages:Version" value="3.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.6" /> 
    <httpRuntime targetFramework="4.6" /> 
    <globalization uiCulture="en-US"/> 
    </system.web> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <system.codedom> 
    <compilers> 
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> 
    </compilers> 
    </system.codedom> 
    <entityFramework> 
    <contexts> 
     <context type="BookMe.Domain.Concrete.BookMeContext, BookMe"> 
     <databaseInitializer type="BookMe.Domain.Concrete.BookMeInitializer, BookMe" /> 
     </context> 
    </contexts> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
</configuration> 

EDIT2: Il est mon fichier .sln:

Sln

+0

Pouvez-vous fournir le web.config – jhen

+0

Oui, je poste édité. Merci pour la réponse. –

+0

Vous avez mentionné que vous avez 3 projets dans le domaine: Domain, WebUI, UnitTests. Où se trouve le projet BookMe, est ce que votre projet de couche de données? Pouvez-vous montrer votre fichier .sln? – Vinod

Répondre

1

Vous devez mettre à jour config EntityFramework pour spécifier l'assemblage correct prénom. Au lieu de type = "BookMe.Domain.Concrete.BookMeContext, BookMe", vous devez utiliser type = "BookMe.Domain.Concrete.BookMeContext, BookMe.Domain". Vous devez le faire partout où vous avez des entrées similaires.

<entityFramework> 
    <contexts> 
     <context type="BookMe.Domain.Concrete.BookMeContext, BookMe.Domain"> 
     <databaseInitializer type="BookMe.Domain.Concrete.BookMeInitializer, BookMe.Domain" /> 
     </context> 
    </contexts> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 

MISE À JOUR: Au minimum le format de type dans le fichier de configuration suit le schéma suivant

type="Fully.Qualified.TypeName, AssemblyName"