news 2026/2/6 11:11:48

在.NET Framework 4.7.2 使用Microsoft.Practices.EnterpriseLibrary.Data配置出错

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
在.NET Framework 4.7.2 使用Microsoft.Practices.EnterpriseLibrary.Data配置出错
1,前言

项目在VS2022下开发的,用的.NET Framework 4.7.2,在Nuget包管理器安装EnterpriseLibrary.Data(6.0.1304)。

2,程序错误信息:

程序执行失败:Database provider factory not set for the static DatabaseFactory. Set a provider factory invoking the DatabaseFactory.SetProviderFactory method or by specifying custom mappings by calling the DatabaseFactory.SetDat前言abases method.

3,解决问方法:
3.0 要配置连接数据库前期 工作。看代码:
DatabaseProviderFactory factory = new DatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(factory); Database db = DatabaseFactory.CreateDatabase("DefaultConnection");
3.1在app.config配置信息
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <!-- 配置Enterprise Library数据模块 --> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/> </configSections> <!-- 2. 指定默认数据库(指向下面connectionStrings中的name) --> <dataConfiguration defaultDatabase="DefaultConnection" /> <!-- 3. 定义连接字符串 --> <connectionStrings> <!-- 以下示例连接字符串,请按您的数据库类型选择并修改 --> <!-- 用于 SQL Server TestSort_num DATA_CMS--> <!--connectionString="Data Source=SK-20320110RSWP;Initial Catalog=TestSort_num;User ID=sa;Password=123;Integrated Security=True;"--> <add name="DefaultConnection" connectionString="Data Source=SK-20320110RSWP;Initial Catalog=DATA_CMS;User ID=sa;Password=123;Integrated Security=True;" providerName="System.Data.SqlClient" /> <!-- 用于 Oracle --> <!-- <add name="YourConnectionStringName" connectionString="User Id=user;Password=pass;Data Source=source;" providerName="System.Data.OracleClient" /> --> <!-- 如果使用其他数据库(如MySQL),可能需要额外在<system.data>节点中注册提供程序 --> </connectionStrings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> </startup> </configuration>

谢谢观看,不是在改Bug路上,就是制造bug缔造者!

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/2/5 8:37:47

nanomsg高性能通信:构建下一代分布式系统的核心技术

nanomsg高性能通信&#xff1a;构建下一代分布式系统的核心技术 【免费下载链接】nanomsg nanomsg library 项目地址: https://gitcode.com/gh_mirrors/na/nanomsg nanomsg是一个革命性的高性能消息传递库&#xff0c;专门为构建可扩展的分布式系统而设计。作为传统消息…

作者头像 李华
网站建设 2026/2/4 15:47:25

ANSYS Fluent UDF高级编程完整手册:深度扩展仿真定制功能

ANSYS Fluent UDF高级编程完整手册&#xff1a;深度扩展仿真定制功能 【免费下载链接】ANSYSFluentUDFManual2020R2官方手册资源下载 本开源项目提供了ANSYS Fluent UDF Manual (2020R2) 的官方PDF文件下载&#xff0c;专为希望在Fluent中进行自定义编程的用户设计。手册详细介…

作者头像 李华
网站建设 2026/1/29 9:35:18

前端开发人员:以下是如何充分利用 Cursor

前端开发人员&#xff1a;如何充分利用 Cursor Cursor 是一个基于 VS Code 的 AI 驱动代码编辑器&#xff0c;专为开发者设计&#xff0c;尤其适合前端工作。它集成了大型语言模型&#xff08;如 Claude 或 GPT&#xff09;&#xff0c;能帮助你快速生成、调试和优化代码。作为…

作者头像 李华
网站建设 2026/2/6 2:40:49

[C语言]双向循环链表的增删改查功能

[C语言]双向循环链表的增删改查功能 1. 前言 本例提供一个可复用的双向循环链表模板&#xff0c;含完整接口与菜单式示例主程序&#xff0c;便于快速集成或学习链表操作。 2. 功能/亮点概览 双向循环 哨兵节点&#xff0c;边界处理简单。增删改查全覆盖&#xff0c;含头/尾…

作者头像 李华
网站建设 2026/2/3 23:24:35

鸣潮玩家必看:5大自动化功能让游戏效率提升300%

鸣潮玩家必看&#xff1a;5大自动化功能让游戏效率提升300% 【免费下载链接】ok-wuthering-waves 鸣潮 后台自动战斗 自动刷声骸上锁合成 自动肉鸽 Automation for Wuthering Waves 项目地址: https://gitcode.com/GitHub_Trending/ok/ok-wuthering-waves 还在为重复的刷…

作者头像 李华
网站建设 2026/2/4 15:28:05

Path of Building终极指南:四大模块打造完美角色构建

Path of Building终极指南&#xff1a;四大模块打造完美角色构建 【免费下载链接】PathOfBuilding Offline build planner for Path of Exile. 项目地址: https://gitcode.com/GitHub_Trending/pa/PathOfBuilding 作为《流放之路》社区最受欢迎的角色构建工具&#xff0…

作者头像 李华