无法加载文件或程序集..系统.数据.实体.dll.
本文关键字:系统 数据 实体 dll 程序集 加载 文件 | 更新日期: 2023-09-27 18:32:55
"
/"应用程序中的服务器错误。
无法加载文件或程序集"file:///C:''程序文件 (x86)''引用程序集''Microsoft''Framework.NETFramework''v4.0''System.Data.Entity.dll"或其依赖项之一。系统找不到指定的文件。
在我的 web.config 文件下面 - 可能有什么问题?如果我登录并使用该应用程序,一切正常。如果我离开应用程序并且下次尝试输入时超过 15 或 20 分钟不使用它,我收到上面的错误
感谢您在高级方面的任何帮助
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<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=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<!--<add name="***" connectionString="Data Source=winserver;Initial Catalog=***;USER ID=***; Password=***; MultipleActiveResultSets=true;" providerName="System.Data.SqlClient"/>-->
<add name="***" connectionString="Data Source=plcentral.ca;Initial Catalog=***;Integrated Security=False; User ID=***;Password=*** providerName="System.Data.SqlClient"/>
<!--<add name="***" connectionString="Data Source=(local);Initial Catalog=***;Integrated Security=True;" providerName="System.Data.SqlClient"/>-->
<!--<add name="***" connectionString="Data Source=.'SQLEXPRESS;AttachDbFilename=|DataDirectory|***.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />-->
<!--<add name="***" connectionString="Data Source=***;Initial Catalog=***;Integrated Security=False; User ID=***;Password=***" providerName="System.Data.SqlClient" />-->
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="PreserveLoginUrl" value="true"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<add key="GoogleAccount" value="email@email.com"/>
<add key="GoogleAccountPwd" value="password"/>
<!--<add key="GoogleAccount" value="email@email.com"/>
<add key="GoogleAccountPwd" value="password"/>-->
</appSettings>
<system.web>
<customErrors mode="Off"/>
<globalization culture="en-US" uiCulture="en-US"/>
<compilation targetFramework="4.0" >
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
<httpRuntime maxRequestLength="20000000"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880"/>
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Web.WebPages"/>
<add namespace="MvcJqGrid"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
<remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%'Microsoft.NET'Framework'v4.0.30319'aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%'Microsoft.NET'Framework64'v4.0.30319'aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Transactions" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Core" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
</entityFramework>
</configuration>
在解决方案资源管理器中
转到"引用" => 右键单击并"添加引用" => 转到".Net"选项卡并添加"系统.数据.实体"。
重建解决方案,希望这有帮助。
您如何为您的项目提供参考/安装实体框架?尝试删除引用并使用Nugget包管理器的安装选项重新安装。它会自动为您配置引用。如果您没有Nugget,则可以从Visual Studio Tools>扩展菜单中添加此扩展。默认情况下,实体框架 dll 不与其他 .net dll 一起存在。
除此之外,我建议您使用EntityFramework版本5而不是您尝试使用的4。v5 中修复了许多配置问题。它还为您提供了代码优先的方法,使用起来很有趣:)
您可以使用
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
https://stackoverflow.com/a/5129828/1310540