无法加载文件或程序集'Oracle.ManagedDataAccess.EntityFramework [英] Could not load file or assembly 'Oracle.ManagedDataAccess.EntityFramework
问题描述
当我想启动我的asp.net Web应用程序时出现此错误
给定的程序集名称或代码库无效。 (来自HRESULT的异常:0x80131047)
...
第22行:{
第23行:public ApplicationDbContext()
第24行::base( DefaultConnection ,throwIfV1Schema:false)
第25行:{
第26行:}
它的MVC Web应用程序连接到oracle数据库,我在NuGet上使用了EntinyFramework 6.1.3。
我正在使用Windows 7 64位,
V.Studio 2015年
和32位ODAC 12c第4版
我试图在Visual Studio中将其设置为以x64或x86开头,这没有帮助。 p>
请给我一些建议。谢谢。
后面的代码:
Web.config:
<配置>
< configSections>
<!-有关实体框架配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468->
< section name = Oracle.ManagedDataAccess.Client type = OracleInternal.Common.ODPMSectionHandler,Oracle.ManagedDataAccess,Version = 4.12.1.0.2.4,Culture = neutral,PublicKeyToken = 89b483f429c47342 />
< section name = entityFramework type = System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089 requirePermission = false /> ;
< sectionGroup name = devExpress>
< section name = themes type = DevExpress.Web.ThemesConfigurationSection,DevExpress.Web.v16.1,Version = 16.1.5.0,Culture = neutral,PublicKeyToken = b88d1754d700e49a requirePermission = false /> ;
< section name = compression type = DevExpress.Web.CompressionConfigurationSection,DevExpress.Web.v16.1,Version = 16.1.5.0,Culture = neutral,PublicKeyToken = b88d1754d700e49a requirePermission = false /> ;
< section name = settings type = DevExpress.Web.SettingsConfigurationSection,DevExpress.Web.v16.1,Version = 16.1.5.0,Culture = neutral,PublicKeyToken = b88d1754d700e49a requirePermission = false /> ;
< section name = errors type = DevExpress.Web.ErrorsConfigurationSection,DevExpress.Web.v16.1,Version = 16.1.5.0,Culture = neutral,PublicKeyToken = b88d1754d700e49a requirePermission = false /> ;
< / sectionGroup>
< / configSections>
< connectionStrings>
<添加名称= DefaultConnection connectionString =数据源=(LocalDb)\MSSQLLocalDB; AttachDbFilename = | DataDirectory | \aspnet-WebApplication1-20160811110342.mdf;初始目录= aspnet-WebApplication1-20160811110342;集成安全性= True
providerName = System.Data.SqlClient />
< add name = Model1 connectionString = DATA SOURCE = XXXXX; PERSIST SECURITY INFO = True; USER ID = XXXX
providerName = Oracle.ManagedDataAccess.Client />
<添加名称= xpf.printing connectionString = xpoprovider = MSSqlServer;数据源=(localdb)\mssqllocaldb; attachdbfilename = | DataDirectory | \ReportService.mdf;集成安全性= True;连接超时= 120英寸/>
< / connectionStrings>
....
< entityFramework>
< defaultConnectionFactory type = System.Data.Entity.Infrastructure.LocalDbConnectionFactory,EntityFramework>
< parameters>
< parameter value = mssqllocaldb />
< / parameters>
< / defaultConnectionFactory>
< providers>
< provider invariantName = Oracle.ManagedDataAccess.Client type = Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices,Oracle.ManagedDataAccess.EntityFramework,Version = 4.12.1.0.2.4,Culture = neutral,PublicKeyToken = 89b483f429c47342 / >
< provider invariantName = System.Data.SqlClient type = System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer />
< / providers>
< / entityFramework>
....
< / configuration>
IdentityModels.cs:
使用System.Data.Entity;
使用System.Security.Claims;
使用System.Threading.Tasks;
使用Microsoft.AspNet.Identity;
使用Microsoft.AspNet.Identity.EntityFramework;
命名空间WebApplication1.Models
{
//您可以通过向ApplicationUser类添加更多属性来为用户添加配置文件数据,请访问http://go.microsoft。 com / fwlink /?LinkID = 317594了解更多信息。
公共类ApplicationUser:IdentityUser
{
public async Task< ClaimsIdentity> GenerateUserIdentityAsync(UserManager< ApplicationUser>管理器)
{
//注意,authenticationType必须与CookieAuthenticationOptions.AuthenticationType
中定义的身份匹配。var userIdentity = await manager.CreateIdentityAsync(this,DefaultAuthenticationTypes.ApplicationCookie);
//在此处添加自定义用户声明
return userIdentity;
}
}
公共类ApplicationDbContext:IdentityDbContext< ApplicationUser>
{
public ApplicationDbContext()
:base( DefaultConnection,throwIfV1Schema:false)
{
}
公共静态ApplicationDbContext创建()
{
返回new ApplicationDbContext();
}
}
}
我有相同的错误,并且已经这样修复:
您需要像这样更改web.config:
< entityFramework>
< defaultConnectionFactory type = Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory,Oracle.ManagedDataAccess.EntityFramework>< / defaultConnectionFactory>
< providers>
< provider invariantName = Oracle.ManagedDataAccess.Client type = Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices,Oracle.ManagedDataAccess.EntityFramework,Version = 6.121.2.0,Culture = neutral,PublicKeyToken = 89b483f429c47342 />
< provider invariantName = System.Data.SqlClient type = System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer />
< / providers>
< / entityFramework>
您需要安装EntityFramework
1.安装软件包EntityFramework -Version 6.1.1
2.从链接设置中添加参考ODAC 12c第4版
Oracle.ManagedDataAccess.EntityFramework.dll
Oracle.ManagedDataAccess.dll到您的项目。
将会完成
I'm getting this error when i want to start my asp.net web app
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
...
Line 22: {
Line 23: public ApplicationDbContext()
Line 24: : base("DefaultConnection", throwIfV1Schema: false)
Line 25: {
Line 26: }
Its MVC web app connected to oracle database and I used EntinyFramework 6.1.3 over NuGet,
I'm using windows 7 64-bit, V.Studio 2015 and 32-bit ODAC 12c Release 4
I tried to set in Visual studio to start in x64 or x86, doesn't help..
Please give me some advice. Thank you.
Code behind: Web.config:
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="Oracle.ManagedDataAccess.Client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.12.1.0.2.4, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="devExpress">
<section name="themes" type="DevExpress.Web.ThemesConfigurationSection, DevExpress.Web.v16.1, Version=16.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="compression" type="DevExpress.Web.CompressionConfigurationSection, DevExpress.Web.v16.1, Version=16.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="settings" type="DevExpress.Web.SettingsConfigurationSection, DevExpress.Web.v16.1, Version=16.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
<section name="errors" type="DevExpress.Web.ErrorsConfigurationSection, DevExpress.Web.v16.1, Version=16.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplication1-20160811110342.mdf;Initial Catalog=aspnet-WebApplication1-20160811110342;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="Model1" connectionString="DATA SOURCE=XXXXX;PERSIST SECURITY INFO=True;USER ID=XXXX"
providerName="Oracle.ManagedDataAccess.Client"/>
<add name="xpf.printing" connectionString="xpoprovider=MSSqlServer;data source=(localdb)\mssqllocaldb;attachdbfilename=|DataDirectory|\ReportService.mdf;integrated security=True;connect timeout=120" />
</connectionStrings>
....
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=4.12.1.0.2.4, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
....
</configuration>
IdentityModels.cs :
using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
namespace WebApplication1.Models
{
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
}
I have the same bug and I has been fixed like this: You need change your web.config like this:
<entityFramework>
<defaultConnectionFactory type="Oracle.ManagedDataAccess.EntityFramework.OracleConnectionFactory, Oracle.ManagedDataAccess.EntityFramework"></defaultConnectionFactory>
<providers>
<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
And you need to install entityFramework 1. Install-Package EntityFramework -Version 6.1.1 2. Add reference from your link setup ODAC 12c Release 4 Oracle.ManagedDataAccess.EntityFramework.dll Oracle.ManagedDataAccess.dll to your project. It's will done
这篇关于无法加载文件或程序集'Oracle.ManagedDataAccess.EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!