CN118210498B - A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# project - Google Patents
A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# projectInfo
- Publication number
- CN118210498B CN118210498B CN202410385292.9A CN202410385292A CN118210498B CN 118210498 B CN118210498 B CN 118210498B CN 202410385292 A CN202410385292 A CN 202410385292A CN 118210498 B CN118210498 B CN 118210498B
- Authority
- CN
- China
- Prior art keywords
- driver
- mysql
- version
- alias
- module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/36—Software reuse
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Computer Security & Cryptography (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to the technical field of computer communication, in particular to a method and a system for simultaneously referring to multi-version Mysql drive by a C# project, wherein the method comprises the following steps of S1, determining Mysql.data driven versions required to be used by two databases with different versions; the method comprises the steps of S2, modifying a digital signature of any Mysql.data driver, marking a driver needing to modify the digital signature as A1 and a driver not needing to modify the digital signature as B, S3, marking the driver after modification as A2, then simultaneously introducing the driver A2 and the driver B into a C# item, S4, selecting a driver with a lower version from the driver A2 and the driver B in the C# item, marking the driver as D, and designating the driver D as V1. The method and the device can solve the problem of drive compatibility caused by the difference of the versions of the databases in the same project, and realize stable and efficient operation in various MySQL database environments.
Description
Technical Field
The invention relates to the technical field of computer communication, in particular to a method and a system for simultaneously referring to multi-version Mysql drivers by a C# project.
Background
In C#, interfacing with a MySQL database typically requires the use of a driver component named Mysql. It is noted that different versions of mysql.data.dll are each adapted to a specific range of MySQL database versions. For example, version 8.0 drive supports multiple versions of databases 8.0, 5.7, 5.6, etc., whereas version 6.5.4.0 drive is applicable to versions 5.0 to 5.7, version 6.1.3.0 drive is applicable to version 4.0 databases. Under the conventional business scene, the development requirement can be met by selecting a driver with a proper version for a single type of MySQL database.
However, in some special scenarios, a challenge is presented in that the same project can connect both a low version 4.0 database and a high version 5.7 database under a set of code systems, which leads to the problem of drive compatibility. This problem becomes particularly troublesome in view of Visual Studio prohibiting the introduction of DLL files of the same name or having the same signature in a single item.
Disclosure of Invention
In order to solve the technical problems, the invention provides a method and a system for simultaneously referencing multi-version Mysql drivers for C# projects, which can solve the problem of drive compatibility caused by database version differences in the same project and realize stable and efficient operation in various MySQL database environments.
The invention is realized by adopting the following technical scheme:
a method for c# items to reference multi-version Mysql drivers simultaneously, the method comprising the steps of:
s1, determining Mysql.data driven versions required to be used by two databases with different versions;
S2, modifying the digital signature of any Mysql.data driver version, and marking the driver needing to modify the digital signature as A1 and the driver not needing to modify the digital signature as B;
S3, marking the modified drive as A2, and then introducing the drive A2 and the drive B into the C# item at the same time;
s4, in the C# item, selecting a lower version of drive from the drive A2 and the drive B, marking the lower version of drive as D, and designating the drive D as V1;
s5, executing an SQL command through a driver D under an alias V1 to inquire the actual version of the database which is currently connected;
And S6, if the version corresponding to the actual version of the database is the driver B, creating connection and executing the query by using the driver B, and if not, creating connection and executing the query by using the driver A2.
Preferably, the step S2 is further specifically that the digital signature is modified by:
first, a KeyFile file is generated;
secondly, deconstructing the driver A1 to generate a corresponding intermediate language file C;
Then, recombining the file C and combining with KeyFile files;
finally, the modification is completed to obtain a drive A2.
Preferably, the step S4 is further specifically that after the drive D is assigned with the alias V1, the external alias is imported through an external alias V1 instruction so as to facilitate the quote to the drive D in the program;
Then two subdirectories are added under the release catalog of the project and are respectively used for storing the drive A2 and the drive B;
Finally, assemblyIdentity elements and corresponding codeBase subelements are added in the Web config configuration file to define specific loading paths of the driver A2 and the driver B, so that a program can select which driver to call.
A system for simultaneously referencing multi-version Mysql drivers for C# items, comprising a determining module, a modifying module, an introducing module, a specified alias module, a querying module and a using module;
the determining module is used for determining Mysql.data driven versions required to be used by the two databases with different versions;
The modification module is used for modifying the digital signature of any Mysql.data driven version, and the driver needing to modify the digital signature is marked as A1 and the driver not needing to modify the digital signature is marked as B;
the introduction module is used for marking the modified drive as A2, and then introducing the drive A2 and the drive B into the C# item at the same time;
The alias assignment module is used for selecting a lower version of drive from the drive A2 and the drive B in the C# item, marking the lower version of drive as D, and assigning the drive D with the alias of V1;
The query module executes SQL command through the driver D under the alias V1 to query the actual version of the database which is currently connected;
and the using module is used for creating connection and executing query by using the driver B if the version corresponding to the actual version of the database is the driver B, and otherwise, creating connection and executing query by using the driver A2.
Preferably, the modification module further specifically modifies the digital signature by:
first, a KeyFile file is generated;
secondly, deconstructing the driver A1 to generate a corresponding intermediate language file C;
Then, recombining the file C and combining with KeyFile files;
finally, the modification is completed to obtain a drive A2.
Preferably, the alias assignment module further specifically assigns an alias name V1 to the driver D, and then imports an external alias name through an external alias V1 instruction so as to facilitate the quotation to the driver D in the program;
Then two subdirectories are added under the release catalog of the project and are respectively used for storing the drive A2 and the drive B;
Finally, assemblyIdentity elements and corresponding codeBase subelements are added in the Web config configuration file to define specific loading paths of the driver A2 and the driver B, so that a program can select which driver to call.
The invention has the beneficial effects that:
The invention provides a method and a system for simultaneously referring to multi-version Mysql drivers for C# projects, which can systematically comb out all MySQL database versions required by the projects according to the diversity of actual service environments, and accurately select each version MySQL driver required to be integrated into the projects based on the versions. Then, an adaptation strategy of digital signature of the original driving file is adopted, the file is renamed and introduced into the project, and the driving components of any version can be freely switched and called in the single file according to the requirement by means of an external alias mechanism of C#.
Drawings
FIG. 1 is a schematic flow chart of the method of the present invention.
Fig. 2 is a system schematic block diagram of the present invention.
FIG. 3 is a schematic diagram of a software Visual Studio 2017.
FIG. 4 is a schematic diagram of generation KeyFile.
Fig. 5 is a schematic diagram of an intermediate language file.
FIG. 6 is a schematic diagram of generating a new Dll file.
FIG. 7 is a schematic diagram of a new signature of a new Dll file.
Fig. 8 is a schematic diagram of a DLL file referencing two versions simultaneously.
Fig. 9 is a schematic diagram of the alias V1.
Fig. 10 is a schematic diagram of importing external aliases.
FIG. 11 is a diagram of a specific load path defining different versions of Mysql.Data drivers.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
Referring to fig. 1, the present invention provides a method for simultaneously referencing multiple versions of Mysql driver for a c# item, the method comprising the following steps:
s1, determining Mysql.data driven versions required to be used by two databases with different versions;
S2, modifying the digital signature of any Mysql.data driver version, and marking the driver needing to modify the digital signature as A1 and the driver not needing to modify the digital signature as B;
S3, marking the modified drive as A2, and then introducing the drive A2 and the drive B into the C# item at the same time;
s4, in the C# item, selecting a lower version of drive from the drive A2 and the drive B, marking the lower version of drive as D, and designating the drive D as V1;
s5, executing an SQL command through a driver D under an alias V1 to inquire the actual version of the database which is currently connected;
And S6, if the version corresponding to the actual version of the database is the driver B, creating connection and executing the query by using the driver B, and if not, creating connection and executing the query by using the driver A2.
The invention is further described with reference to the following specific examples:
A method for simultaneously referencing multi-version Mysql drive by C# items,
Step 1, determining Mysql.data driven versions required to be used by two databases with different versions;
For example, according to the business condition, the Mysql.data driving version needed to be used by the high version library and the low version library is determined. For example, mysql 5.7 version database corresponds to mysql.data.dll 6.5.4.0, mysql4.0 version database corresponds to mysql.data.dll 6.1.3.0;
Step 2, modifying the digital signature of any Mysql.data driver version, and marking the driver needing to modify the digital signature as A1 and the driver not needing to modify the digital signature as B;
The digital signature is modified by:
first, a KeyFile file is generated;
secondly, deconstructing the driver A1 to generate a corresponding intermediate language file C;
Then, recombining the file C and combining with KeyFile files;
finally, the modification is completed to obtain a drive A2.
For example, select 6.1.3.0 version to modify a driver signature
(1) As in fig. 3, a developer command prompt running Visual Studio 2017 with administrator identity;
(2) As shown in FIG. 4, the command line page, input command sn-k keyPair. Sink, generates one KeyFile;
(3) As shown in FIG. 5, a command line page, input command ildasm D: \level\MySql. Data. Dll/out: D: \level\MySql. Data. Il gets an intermediate language file and outputs to under the D: \level\directory;
(4) As shown in FIG. 6, the command line page, input command ilasm D \level\MySql.data/Dll/key: key Pair.sink, generates a new Dll file using the derived MSIL (MySql.data.il) and the just created KeyFile;
(5) Referring to FIG. 7, a new signed Mysql.Data.dll file is obtained under the file directory, and the signature of the Dll file is modified to 98a540a6f88622c5 by decompilation and viewing;
Step 3, marking the modified drive as A2, and then introducing the drive A2 and the drive B into the C# item at the same time;
For example, as shown in FIG. 8, mysql.Data.6.1.3.0.dll file and 6.5.4.0 Mysql.data.dll file are referenced simultaneously in the project, where both versions of DLL files can be referenced simultaneously.
Step 4, in the C# item, selecting a lower version of drive from the drive A2 and the drive B, marking the lower version of drive as D, and designating the drive D as V1;
after the name of the driver D is designated as V1, the external alias is imported through an external alias V1 instruction so as to be beneficial to the fact that the driver D can be quoted in a program;
Then two subdirectories are added under the release catalog of the project and are respectively used for storing the drive A2 and the drive B;
Finally, assemblyIdentity elements and corresponding codeBase subelements are added in the Web config configuration file to define specific loading paths of the driver A2 and the driver B, so that a program can select which driver to call.
For example, (1) as in FIG. 9, alias "V1" is made for the newly referenced Mysql.Data.6.1.3.0. Dll;
(2) In the related operation class, as shown in fig. 10, the external aliases V1 instruction is used to import the external aliases.
(3) And seventhly, adding two subdirectories under the release catalog of the project to respectively store two versions of drive files:
bin/Mysql.Data/6.1.3.0/Mysql.Data.dll;
bin/Mysql.Data/6.5.4.0/Mysql.Data.dll;
(4) As shown in FIG. 11, elements assemblyIdentity and corresponding codeBase subelements are added to a Web.config profile to define specific load paths for different versions of Mysql.Data drivers.
Step 5, executing SQL command through the driver D under the alias V1 to inquire the actual version of the database which is currently connected;
For example, an SQL command, such as select @ @ version, is executed by a driver under the alias "V1" to query the actual version of the database currently connected.
And 6, if the version corresponding to the actual version of the database is the driver B, creating connection and executing query by using the driver B, and if not, creating connection and executing query by using the driver A2.
For example, if version 4.0, a connection is established and a related query operation for MySQL 4.0 database is performed using a driver labeled "V1". If version 5.7, the original 6.5.4.0 version mysql.data.dll driver is used to create a connection and execute the query.
With continued reference to fig. 2, the present invention further provides a system for simultaneously referencing multiple versions of Mysql drivers for a c# item, where the system includes a determining module, a modifying module, an introducing module, an alias assignment module, a query module, and a using module;
the determining module is used for determining Mysql.data driven versions required to be used by the two databases with different versions;
The modification module is used for modifying the digital signature of any Mysql.data driven version, and the driver needing to modify the digital signature is marked as A1 and the driver not needing to modify the digital signature is marked as B;
the introduction module is used for marking the modified drive as A2, and then introducing the drive A2 and the drive B into the C# item at the same time;
The alias assignment module is used for selecting a lower version of drive from the drive A2 and the drive B in the C# item, marking the lower version of drive as D, and assigning the drive D with the alias of V1;
The query module executes SQL command through the driver D under the alias V1 to query the actual version of the database which is currently connected;
and the using module is used for creating connection and executing query by using the driver B if the version corresponding to the actual version of the database is the driver B, and otherwise, creating connection and executing query by using the driver A2.
Preferably, the modification module further specifically modifies the digital signature by:
first, a KeyFile file is generated;
secondly, deconstructing the driver A1 to generate a corresponding intermediate language file C;
Then, recombining the file C and combining with KeyFile files;
finally, the modification is completed to obtain a drive A2.
Preferably, the alias assignment module further specifically assigns an alias name V1 to the driver D, and then imports an external alias name through an external alias V1 instruction so as to facilitate the quotation to the driver D in the program;
Then two subdirectories are added under the release catalog of the project and are respectively used for storing the drive A2 and the drive B;
Finally, assemblyIdentity elements and corresponding codeBase subelements are added in the Web config configuration file to define specific loading paths of the driver A2 and the driver B, so that a program can select which driver to call.
In a word, according to the diversity of the actual service environment, all MySQL database versions required by the project can be systematically carded out, and on the basis of the versions, mySQL drivers which need to be integrated into the project are accurately selected. Then, an adaptation strategy of digital signature of the original driving file is adopted, the file is renamed and introduced into the project, and the driving components of any version can be freely switched and called in the single file according to the requirement by means of an external alias mechanism of C#.
The above description is only of the preferred embodiments of the present application, and should not be construed as limiting the application, but rather as covering all equivalent variations and modifications according to the appended claims.
Claims (6)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410385292.9A CN118210498B (en) | 2024-04-01 | 2024-04-01 | A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# project |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410385292.9A CN118210498B (en) | 2024-04-01 | 2024-04-01 | A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# project |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118210498A CN118210498A (en) | 2024-06-18 |
CN118210498B true CN118210498B (en) | 2025-09-26 |
Family
ID=91447387
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410385292.9A Active CN118210498B (en) | 2024-04-01 | 2024-04-01 | A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# project |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118210498B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102804132A (en) * | 2009-06-15 | 2012-11-28 | 微软公司 | Catalog-based software component management |
CN106250726A (en) * | 2016-08-10 | 2016-12-21 | 深圳金澜汉源科技有限公司 | Software version state management-control method |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110688661A (en) * | 2019-08-30 | 2020-01-14 | 深圳壹账通智能科技有限公司 | Method and device for preventing dynamic link library file hijacking and computer equipment |
CN111679871A (en) * | 2020-08-11 | 2020-09-18 | 上海冰鉴信息科技有限公司 | Database driver loading method and database driver loading device |
CN117369842A (en) * | 2022-06-30 | 2024-01-09 | 中兴通讯股份有限公司 | System update file configuration method, system update method, device and storage medium |
CN116483388A (en) * | 2023-03-30 | 2023-07-25 | 浪潮(山东)计算机科技有限公司 | System filling method, device, equipment and medium based on multiple configuration requirements |
-
2024
- 2024-04-01 CN CN202410385292.9A patent/CN118210498B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102804132A (en) * | 2009-06-15 | 2012-11-28 | 微软公司 | Catalog-based software component management |
CN106250726A (en) * | 2016-08-10 | 2016-12-21 | 深圳金澜汉源科技有限公司 | Software version state management-control method |
Also Published As
Publication number | Publication date |
---|---|
CN118210498A (en) | 2024-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109840429B (en) | Intelligent contract deployment and calling method and device | |
US10324690B2 (en) | Automated enterprise software development | |
US6651240B1 (en) | Object-oriented software development support apparatus and development support method | |
US8028268B2 (en) | System and method for building software package for embedded system | |
US20120011496A1 (en) | Service providing apparatus, service providing system, method of processing data in service providing apparatus, and computer program | |
JP4179557B2 (en) | System, method and computer program for performing legacy application migration | |
US20110302565A1 (en) | Implicit workspace dependencies | |
US20050160104A1 (en) | System and method for generating and deploying a software application | |
CN105760168A (en) | Automatic code file generation method and system | |
EP4049131B1 (en) | Modifying program modules in running applications | |
CN113434194A (en) | Continuous integration and delivery system, method, electronic device and storage medium | |
CN116450107B (en) | Method and device for secondary development of software by low-code platform and electronic equipment | |
CN112685091A (en) | Service request processing method, device, equipment and medium based on big data | |
US7926052B2 (en) | Stacked file systems and methods | |
CN118210498B (en) | A method and system for simultaneously referencing multiple versions of MySQL drivers in a C# project | |
US20090193392A1 (en) | Dynamic intermediate language modification and replacement | |
CA2353026A1 (en) | Adaptive data architecture | |
CN110544092B (en) | Dynamic newly-added multi-type database data operation chaining method for block chain | |
CN113296749A (en) | Code generation method, device, equipment and computer readable storage medium | |
CN114721647B (en) | An Object-Oriented Programming Method Based on Codeless Application Development | |
CN115878163A (en) | Automatic annotation method, terminal device, and computer-readable storage medium | |
CN114281818A (en) | Data processing method, device, server and storage medium | |
CN116909545A (en) | Low-code MOM platform based on micro-service architecture | |
JP2004110102A (en) | Project management method and process definition device | |
CN116909567A (en) | Code automatic generation method and device, medium and equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |