简体   繁体   English

如何使用web.config删除DbProviderFactories?

[英]How remove DbProviderFactories using web.config?

I have problem with my ASP.NET MVC app which is using SQLSERVER 2012 Expresss for security and somehow this is conflicting with my Firebird installation which is not used in this case. 我的ASP.NET MVC应用程序有问题,它使用SQLSERVER 2012 Expresss来保证安全性,并且这与我在这种情况下不使用的Firebird安装有冲突。 Getting exception like this: 得到这样的异常:

An error occurred creating the configuration section handler for system.data: Column 'InvariantName' is constrained to be unique. 为system.data创建配置节处理程序时发生错误:列'InvariantName'被限制为唯一。 Value 'FirebirdSql.Data.FirebirdClient' is already present. 值'FirebirdSql.Data.FirebirdClient'已存在。

I have tried to enter in my web.config this: 我试图在我的web.config中输入:

<remove invariant="FirebirdSql.Data.FirebirdClient"/>

but that didn't work, what I have finally do I have removed this firebird entry from machine.config: 但这不起作用,我终于做了什么,我从machine.config中删除了这个firebird条目:

<system.data>
<DbProviderFactories>
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=3.0.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/><add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=3.0.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/></DbProviderFactories>

and that worked out, but th is not ideal solution bcause I still need firebird to use sometimes. 并且结果很好,但这并不是理想的解决方案,因为我有时候还需要使用firebird。 Anyway to disable this entry temporarily in app web,config? 无论如何要暂时在app web,config中禁用此条目? Also, why I am getting such conflict to start with anyway? 另外,为什么我要开始这样的冲突呢? thanks 谢谢

You have the same record in machine.config twice. 您在machine.config中有两次相同的记录。 Remove one and you'll be fine. 删除一个,你会没事的。

I have a similar problem and ended up with a different solution. 我有类似的问题,最终得到了一个不同的解决方案。

What happen is that I started developing my Web application in the default (root) folder IIS creates. 发生的事情是我开始在IIS创建的默认(根)文件夹中开发我的Web应用程序。

After that, for testing purposes I changed this option to work in a deeper folder in the same domain: 之后,出于测试目的,我将此选项更改为在同一域中的更深层文件夹中工作:

项目属性 - > Web

I added the name and clicked " Create Virtual Directory ". 我添加了名称,然后单击“ 创建虚拟目录 ”。 The application ran but gave me the similar problem. 该应用程序运行但给了我类似的问题。

What happen is that when I created the second virtual directory IIS express leave the first one there pointing to the same location. 发生的事情是,当我创建第二个虚拟目录时, IIS快速离开第一个指向同一位置的虚拟目录。 So I have the same app twice sharing Web.config hierarchically. 所以我有两个相同的应用程序两次分层共享Web.config。

Solution to my problem 解决我的问题

To solve this I just changed the port so the previous created virtual directory is not my root anymore. 为了解决这个问题,我刚刚更改了端口,因此以前创建的虚拟目录不再是我的root用户了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM