Cross-operating-system. NET runtime calling method and CAD secondary development method and system
By dynamically loading the hostfxr dynamic library under the Linux operating system and calling the necessary functions of the .NET runtime, combined with the encapsulation and data type conversion of the C++ interface, the problem of being unable to directly call the CAD.NET application plug-in developed by the Windows.NET platform under Linux is solved, and efficient cross-platform CAD secondary development is achieved.
Patent Information
- Application Number
- CN202411896497.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-05-30
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-20
AI Technical Summary
It is difficult for the existing technology to directly call and run CAD.NET application plug-ins developed based on the Windows.NET platform under the Linux operating system, and the mono software's performance and update speed are insufficient to meet the needs of developers.
By dynamically loading the hostfxr dynamic library, the necessary functions of the .NET runtime are called under the Linux operating system, the .NET runtime running environment is built, and the C++ interface is batch encapsulated into a C# interface, and the CAD data type is converted to a CAD data type to achieve cross-platform secondary development.
It realizes the operation of .NET programs under Linux, improves the efficiency and performance of CAD secondary development, supports multi-CPU architecture and multi-system operation, and has broad application prospects.
Smart Images

Figure CN119759344A_ABST
Abstract
Description
[0001] Priority application This application claims priority to the Chinese invention patent application [Application Number: 202410692289.1] [Invention Name: A method, system and storage medium for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform] filed by the applicant on May 30, 2024, which is incorporated by reference in its entirety. Technical Field
[0002] The present invention belongs to the technical field of CAD development, and in particular relates to a cross-operating system .NET runtime calling method and a CAD secondary development method and system based on .NET runtime. Background Art
[0003] Domestic CAD secondary development is in the exploratory stage, and the secondary development ecosystem is immature, especially the .NET ecosystem. For example, there are a large number of .NET application plug-ins based on the CAD platform, and .NET is a development platform under the Windows operating system. The application plug-ins developed through it cannot be directly called under other operating systems such as the Linux operating system. Therefore, running programs developed on the .NET platform under other operating systems such as the Linux operating system has become an urgent problem to be solved in the secondary development of CAD under other operating systems such as the Linux operating system.
[0004] At present, multiple languages and editors can be used on the .NET platform, providing an environment for many open source enthusiasts, so that .NET programs are not limited to the Windows platform. Through the built-in C# language compiler and various class libraries, .NET programs can run on Windows, Linux, Solaris and other operating systems. For example, in the Linux operating system, the existing mono is an open source .NET cross-platform implementation method, which allows developers to run and develop applications based on the .NET framework. However, it runs slowly and is updated slowly, which cannot meet the requirements of developers.
[0005] Prior art Chinese patent application CN202211330751.0 discloses a service deployment method, apparatus, device and readable storage medium, in which the Power server obtains the executable target file of the .NET program; copies the executable target file to the target directory; and uses the deployed mono software to execute the executable target file in the target directory. First, obtain the executable target file of the .NET program, and copy the executable target file to the target directory. Then use the deployed mono software to execute the executable target file in the target directory. In this way, the executable target file of the .NET program can be executed in the Power server. That is, the .NET application is successfully ported to the Linux on Power operating system, which is convenient for developers to use.
[0006] In the above prior art, cross-platform operation of .NET applications is achieved through mono. However, as mentioned above, the limitations of mono software itself restrict the performance of .NET applications.
[0007] In addition, since .NET is developed based on the Windows platform, it uses the C# language. Other operating systems such as Linux are developed based on the C++ language, and C++ and C# have different data types. In addition, the CAD platform under Linux and other operating systems and the CAD platform under .NET also have different data types. The difference in data types is also a huge obstacle to cross-platform secondary development. Summary of the invention
[0008] The purpose of the present invention is to provide a method and system for CAD secondary development embedded in .NET runtime under Linux, which partially solves or alleviates the above-mentioned deficiencies in the prior art, enables .NET programs to run under Linux and convert data types through interface encapsulation, thereby realizing cross-platform secondary development of CAD.
[0009] In order to solve the above-mentioned technical problems, the present invention specifically adopts the following technical solutions: A first aspect of the present invention is to provide a method for CAD secondary development based on .NET runtime, which comprises: In a first operating system or a first operating environment, dynamically load a hostfxr dynamic library, and call necessary functions in the hostfxr dynamic library for the .NET runtime to run in the first operating system or the first operating environment, so as to build a second operating environment in the first operating system or the first operating environment for the .NET runtime, so that the .NET program can run in the first operating system or the first operating environment; In the first operating system or the first operating environment, the C++ interfaces are batch packaged into C# interfaces; and when batch packaging is performed, the CAD data type is converted into the CAD data type under .NET; The step of calling the necessary functions of the .NET runtime running in the first operating system or the first operating environment includes: Parsing several dynamic library files in the dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; Grouping the functions in the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables; According to the preset calling rules, the corresponding function is called for verification according to the address information in the grouping symbol subtable; Make the function that verifies success a required function.
[0010] Preferably, the first operating system is a Linux operating system.
[0011] Preferably, the first operating environment is a C++ operating environment.
[0012] Preferably, the second operating environment is an operating environment of a C# interface, or a .NET environment.
[0013] Preferably, the preset grouping rules include: grouping functions having the same prefix, originating from the same dynamic library file and belonging to the same initialization function module into one group; marking the function group into a necessary function group and a functional function group according to function attributes.
[0014] Preferably, the preset calling rule includes: preferentially calling functions in a necessary function group for verification.
[0015] More preferably, the preset calling rules also include: prioritizing multiple grouping symbol sub-tables based on the number of times each grouping symbol sub-table is successfully loaded under different environments, wherein the higher the number of successful loadings, the higher the priority, and loading is performed in order from high to low until successfully loaded.
[0016] Preferably, the step of converting the data type of CAD in the first operating system or the first operating environment to the data type of CAD in .NET includes: Obtaining a data type rule of CAD in the first operating system or the first operating environment and a data type rule of CAD in .NET; Constructing a conversion grammar rule for converting the data type of CAD in the first operating system or the first operating environment into the data type of CAD in .NET according to the acquired data type rule; The data types of CAD in the first operating system or the first operating environment are batch converted into the data types of CAD in .NET by using the conversion grammar rules.
[0017] Preferably, the data types of CAD in the first operating system or the first operating environment are automatically converted in batches to the data types of CAD in .NET by writing the conversion grammar rules into a script.
[0018] A second aspect of the present invention is to provide a cross-operating system .NET runtime calling method, which comprises the steps of: Dynamically load the hostfxr dynamic library, and parse several dynamic library files in the hostfxr dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; The functions in the symbol table are grouped according to a preset grouping rule to obtain a plurality of grouping sub-tables; wherein the preset grouping rule includes: grouping functions having the same prefix, originating from the same dynamic library file and belonging to the same initialization function module into one group; marking the function group into a necessary function group and a functional function group according to function attributes; According to the preset calling rules, and according to the address information in the grouping symbol subtable, the corresponding function is called for verification; wherein the preset calling rules include: preferentially calling the functions in the necessary function group for verification; The successfully verified function is regarded as a necessary function, and the necessary function is called.
[0019] Preferably, the preset calling rules also include: prioritizing multiple grouping symbol sub-tables based on the number of times each grouping symbol sub-table is successfully loaded under different environments, wherein the higher the number of successful loadings, the higher the priority, and loading is performed in order from high to low until successfully loaded.
[0020] A third aspect of the present invention is to provide a system for performing CAD secondary development based on .NET runtime, which includes: An operating environment building module is used to dynamically load a hostfxr dynamic library in a first operating system or a first operating environment, and call necessary functions of the .NET runtime in the first operating system or the first operating environment in the hostfxr dynamic library, so as to build a second operating environment in the first operating system or the first operating environment for the .NET runtime, so that the .NET program can be run in the first operating system or the first operating environment; The interface encapsulation module is used to encapsulate the C++ interface into a C# interface in the first operating system or the first operating environment; when performing interface encapsulation, the data type of CAD in the first operating system or the first operating environment is converted into the data type of CAD in .NET.
[0021] Preferably, the operating environment building module is specifically used to parse several dynamic library files in the dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; and the functions in the symbol table are grouped according to preset grouping rules to obtain several grouping sub-tables; then according to the preset calling rules, and based on the address information in the grouping symbol sub-table, the corresponding function is called for verification, and the successfully verified function is used as a necessary function.
[0022] Beneficial effect: As mentioned above, there are a large number of .NET application plug-ins in the CAD platform, and most of the existing .NET application plug-ins are developed on the .NET development platform under the Windows operating system. Therefore, a large number of .NET application plug-ins in the CAD platform cannot be directly called or loaded in other operating systems, such as the Linux operating system. Although the Linux operating system has a mono runtime (mono is an open source project designed to make .NET run on Linux. It can make .NET applications run on different operating systems such as Windows, Linux, Solaris, etc. through the built-in C# language compiler, CLR runtime and various class libraries), it has many problems such as slow operation and slow update speed. In addition, the CAD platform has its own professional particularity, so that users cannot conveniently and quickly carry out secondary development of CAD's .NET plug-in directly under operating systems such as Linux. In view of this, the purpose of the present invention is to realize the call of the .NET runtime across operating systems, so as to carry out secondary development of .NET plug-ins in CAD under other operating systems, such as the Linux operating system. For example, by implementing the call of the .NET runtime across operating systems, the .NET runtime (preferably, the .NET7 runtime) is embedded in the Linux GCAD platform, facilitating communication between the host and the .NET plug-in, and providing a complete set of C# interfaces to facilitate secondary development by secondary development users.
[0023] The present invention loads the environment in which .NET can run in a C++ environment (e.g., operating systems such as Linux) through dynamic loading, that is, finds the necessary functions (e.g., initialization-related functions) that provide the operating environment for .NET in the dynamic library, and loads them to build the .NET operating environment, so that the C# interface after subsequent encapsulation can run smoothly. On the other hand, by building a dedicated conversion grammar rule to realize the conversion of CAD data types between two platforms (e.g., Dotnet platform and CAD platform under Linux operating system), batch C++ interface encapsulation is realized, so that users can arbitrarily call the .NET runtime through the C# interface for secondary development.
[0024] The present invention also includes the following benefits: High operating efficiency. Based on the high-performance desktop .NET7 environment provided by Microsoft, CAD runs more efficiently on the Linux operating system.
[0025] Timely updates, based on Microsoft's strong support for .NET7, the platform is updated quickly, and the CAD platform can switch to the latest .NET7 runtime at no cost.
[0026] GUI systems such as Avalonia can be used to support the Linux GCAD platform, but MONO does not support it.
[0027] It supports multiple CPU architectures and multiple systems. It can run on architectures such as x86, arm, loongarch64, domestic systems such as Kylin, Tongxin UOS, Zhongke Fangde, ZTE New Support Point, and internationally renowned operating systems such as Ubuntu and Centos.
[0028] The present invention can be widely used in the fields of mechanical design, architectural design, industrial design, etc., can provide strong support to secondary development manufacturers, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, each element or part is not necessarily drawn according to the actual scale. Obviously, the drawings described below are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without paying creative labor.
[0030] Figure 1 This is a flow chart of Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of some so files in the dynamic library; Figure 3 This is a diagram of the names and addresses of some necessary functions in the symbol table; Figure 4 This is a diagram of the names and addresses of some optional functions (functional functions) in the symbol table; Figure 5 This is a schematic diagram of the key data types of CAD in the C++ environment; Figure 6 for Figure 5 The key data types shown are converted into the key data types diagram of CAD in C# environment; Figure 7 for Figure 5 The key data type shown is converted to Figure 6 Examples of conversion syntax rules for the key data types shown; Figure 8 This is a partial screenshot of the C# interface obtained by batch encapsulating the C++ interface using the invented encapsulation method; Fig. 9 This is a flowchart of Embodiment 3 of the present invention; Fig.10 This is a flow chart of Embodiment 5 of the present invention; Fig.11 This is a flow chart of Embodiment 7 of the present invention; Fig.12 This is a system framework diagram of Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0032] Herein, the suffixes such as "module", "component" or "unit" used to represent elements are used only to facilitate the description of the present invention and have no specific meaning in themselves. Therefore, "module", "component" or "unit" can be used in a mixed manner. Herein, the orientation or position relationship indicated by the terms "upper", "lower", "inner", "outer", "front", "back", "one end", "the other end" and the like are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance. Herein, unless otherwise clearly specified and limited, the terms "installed", "provided with", "connected" and the like should be understood in a broad sense, for example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, a direct connection, an indirect connection through an intermediate medium, or a communication between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood in specific circumstances. Herein, "and / or" includes any and all combinations of one or more of the listed related items. Herein, "plurality" means two or more, that is, it includes two, three, four, five, etc.
[0033] Definition of noun: "Linux": is a free and open source Unix-like operating system. It is released under the GNU General Public License and is free to obtain and use. The Linux operating system kernel was first released by Linus Torvalds in 1991.
[0034] "Windows": is an operating system developed by Microsoft Corporation. It was first released in 1985 and has become one of the most widely used desktop operating systems in the world.
[0035] "C++": is a general-purpose programming language designed and implemented by Bjarne Stroustrup in the early 1980s to extend the functionality of the C language. It is a superset of the C language with the addition of object-oriented programming (OOP) features.
[0036] "C#": is an object-oriented programming language developed by Microsoft. It is one of the main languages of the .NET Framework.
[0037] ".NET": is a software development platform developed by Microsoft to simplify application development, deployment, and management. It was originally released in 2002 and is now an open source platform that supports multiple programming languages, such as C#.
[0038] ".NET runtime": One of the core components of the .NET framework, responsible for executing .NET applications.
[0039] ".Net Core": Using the cross-platform Common Intermediate Language (CIL) technology, the compiler converts the code written in the high-level language into CIL code, and then at runtime, the .Net Core runtime environment (CLR) converts the CIL code into the native code of the target platform.
[0040] "CAD (Computer-Aided Design)" refers to the process of designing, analyzing and manufacturing using computer technology. CAD software is widely used in engineering, architecture, product design and other fields. CAD software can run under Windows system (such as AutoCAD) or Linux system (such as GstarCAD).
[0041] "Dotnet": is a cross-platform development framework launched by Microsoft, which can help developers create efficient, reliable and secure applications on different operating systems. Dotnet provides a series of tools and libraries, including C# programming language, ASP.NET, Entity Framework, etc. These tools and libraries can greatly simplify the application development process and improve development efficiency. The Dotnet framework is constantly developing and improving. The latest Dotnet Core version has the advantages of higher performance, smaller memory usage, faster startup time, etc. At the same time, Dotnet Core also supports running on non-Windows platforms such as Linux and MacOS, which makes the Dotnet framework have a wider application prospect in the field of cross-platform development.
[0042] "Required functions" refers to the most basic functions required to build a running environment for Dotnet core, such as initialization-related functions in dynamic libraries. Of course, in addition to the required functions (i.e., call objects), dynamic libraries also include optional functions that users can choose according to actual needs.
[0043] “Secondary development” refers to further development and customization based on existing software or platforms (for example, the CAD platform in the present invention) to meet specific needs or expand original functions.
[0044] "Initialization function module": is a function package used to implement initialization, which includes multiple necessary functions. Usually a software or application will have different initialization modes in different operating environments (or operating systems). Accordingly, an initialization function module corresponds to an initialization mode. Usually, a so file includes multiple initialization function modules.
[0045] "Operation environment" refers to the various conditions required for the operation of software or various plug-ins, including hardware environment and software environment. For example, Linux operating system (also known as C++ operating environment), Windows operating system, Dotnet (C# operating environment), etc. It can also be a special software platform developed by the software developer himself, such as GCAD platform, or an application. Among them, the C++ operating environment includes various operating systems, such as Linux operating system.
[0046] "Dynamic loading": In this article, dynamic loading refers to the dynamic process of calling or loading the corresponding calling objects, such as necessary functions, one by one for trial operation until finally finding a running environment that can run successfully, that is, obtaining Dotnet core.
[0047] hostfxr is the abbreviation of ".NET Host FX Resolver", where "FX" stands for "Framework".
[0048] As mentioned above, since most of the .NET application plug-ins in CAD are developed on the .NET development platform under the Windows operating system, a large number of .NET application plug-ins in the CAD platform cannot be directly called or loaded in other operating systems (such as the Linux operating system). In order to call the .NET application plug-ins in CAD in other operating systems, it is necessary to build the operating environment required by the .NET runtime in the corresponding operating system, so as to realize the call of the .NET runtime under the operating system, and then realize the secondary development of CAD under the operating system.
[0049] In view of this, the present invention proposes the concept of dynamic loading, that is, through dynamic loading, the necessary functions of the .NET runtime running in other operating systems (such as the Linux operating system) are found and called in the dynamic library, thereby building an operating environment for the .NET runtime under the operating system, so that the .NET program can run under the operating system, that is, the .NET runtime can be called arbitrarily under the operating system, and further secondary development of the .NET application plug-in in the CAD can be carried out.
[0050] Take the secondary development of CAD based on .NET runtime under Linux operating system as an example: first, dynamically load the hostfxr dynamic library of Windows operating system under Linux operating system (i.e., the first operating environment), and find the necessary functions required for .NET runtime to run under Linux operating system, so as to build the environment required by .NET runtime, i.e., .NET environment or .NET platform (i.e., the second operating environment); then, under Linux operating system, convert the data types of CAD platform (i.e., the third operating environment) and the data types of .NET platform into data types under Linux operating system.
[0051] The following describes it in detail with reference to specific embodiments.
[0052] Example 1: Figure 1 As shown, the present invention provides a method for CAD secondary development based on .NET runtime, and the specific steps include: S1 dynamically loads the hostfxr dynamic library in the first operating system or the first operating environment and calls the necessary functions of the .NET runtime in the hostfxr dynamic library for running in the first operating system or the first operating environment, and builds a second operating environment for the .NET runtime in the first operating system or the first operating environment, so that the .NET program can run in the first operating system or the first operating environment.
[0053] .NET programs developed on the .NET platform include applications and plug-ins, which can generally only run under the Windows system. If you want to run the .NET program under other operating systems, such as the Linux operating system, you need to establish a running environment for it, that is, to build a NET environment (or NET platform). The .NET runtime (.NET runtime), as one of the core components of the .NET framework, is responsible for executing .NET applications and is a necessary condition for the operation of .NET programs. Therefore, in this embodiment, in order to call a .NET application plug-in on a CAD platform under a first operating system (such as a Linux operating system) other than the Windows operating system (referred to as the second operating system), the .NET runtime must first be run under the first operating system (such as the Linux operating system).
[0054] Taking the Linux operating system as an example, first load Microsoft's hostfxr dynamic library, call the necessary functions of the .NET runtime running under the Linux operating system in the hostfxr dynamic library, and thus build the second operating environment of the .NET runtime under the Linux operating system, that is, the NET environment. Hostfxr is a key dynamic library (DLL) in the .NET platform, which is mainly responsible for hosting the runtime environment of .NET applications. The hostfxr dynamic library is a relatively complex library that contains multiple functions for handling tasks such as configuration, loading and management of the runtime environment of .NET applications. Since the internal implementation of hostfxr is closed source (although the .NET runtime itself is open source), the specific number and names of functions are not fully disclosed. In other words, among the many functions in the hostfxr dynamic library, it is not known which functions are necessary functions for the .NET runtime to run under other operating systems (such as the Linux operating system), so it is necessary to find the necessary functions for the .NET runtime to run under the first operating system (such as the Linux operating system) from the dynamic library.
[0055] The steps of searching for necessary functions in this embodiment include: S11 parses several dynamic library files to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function. Figure 2 As shown, there are several so files (dynamic library files) in the hostfxr dynamic library. The structure of the so file is very complex, including ELF file format, code segment, data segment, read-only data segment, BSS segment, symbol table, relocation information, dynamic segment, string table, debugging information, etc. Among them, the symbol table contains the names and addresses of functions and variables for use by the linker and dynamic linker. In the linking stage, the symbol table is used to resolve external references; during dynamic loading, the symbol table is used to find and bind symbols. In this step, the so file is parsed to obtain the symbol table in the so file, thereby obtaining the name and position of the function in the symbol table, as shown in Figure 3 , Figure 4 shown.
[0056] S12 groups the functions in the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables, as shown in Table 1: Table 1 Grouping symbol subtable The preset grouping rules described in this embodiment refer to: 1. Group functions that have the same prefix, come from the same dynamic library file, and belong to the same initialization function module into one group.
[0057] Functions from the same so file and the same initialization function module often have close functional correlation, data sharing, initialization dependency, resource management, security, and performance optimization. By grouping these functions together, you can better organize code, manage resources, improve performance, and ensure system stability and security, including: 1. Module cohesion. Functional relevance: These functions usually serve the same functional module or subsystem, and they jointly implement a specific set of functions or business logic. For example, each function in a database access module may be used for database operations (such as insert, delete, query, etc.). Data sharing: These functions may operate on the same internal data structure or state, so they need to share the same data context. For example, each function in a graphics rendering module may need to access the same geometry data or texture data.
[0058] 2. Dependencies. Code dependencies: Functions in the same functional module usually call or depend on each other. For example, a function in a file processing module may call another function to perform file reading and writing operations. Resource dependencies: These functions may depend on the same resources or external services. For example, functions in a network communication module may all need to access the same network socket or configuration.
[0059] 3. Initialization and life cycle management. Initialization order: Functions in the same functional module may need to be initialized in a specific order when the program starts. After grouping, it can ensure that these functions are initialized in the correct order to avoid errors caused by uninitialized functions. Resource release: These functions may need to release resources uniformly at the end of the program. After grouping, it can ensure that all related resources are correctly released at the end of the module life cycle.
[0060] 4. Consistency and security. Security check: Functions in the same functional module may need to undergo the same security check or permission verification. After grouping, unified security settings and checks can be performed at the module level, simplifying code implementation and maintenance. Error handling: These functions may share the same error handling mechanism. For example, all file processing functions may have a unified error handling process when encountering an error.
[0061] 5. Performance optimization. Cache utilization: Functions in the same functional module may operate on the same data structure. Grouping can better utilize the CPU cache and reduce cache misses, thereby improving operating efficiency. Resource management: These functions may need to manage the same type of resources (such as memory, file handles, etc.). Grouping can manage these resources more efficiently and reduce resource competition and conflicts.
[0062] It can be seen that functions from the same so file and the same initialization function module are more conducive to finding necessary functions for the .NET runtime to run under Linux.
[0063] 2. Mark the function groups into necessary function groups and functional function groups (optional function groups) according to function attributes.
[0064] The functions in the hostfxr dynamic library are roughly divided into two groups: necessary function group and functional function group. Necessary functions refer to functions that must be called during the operation of the .NET runtime, that is, the .NET runtime cannot proceed without this function. Depending on the operating environment, for example, different operating systems call different functions. Functional functions refer to functions called by .NET to achieve certain functions, which are not necessary for operation. It can be understood that classifying the properties of functions is conducive to quickly finding necessary functions for the .NET runtime to run under Linux. To distinguish between necessary functions and functional functions, they can generally be distinguished by the prefix of the function name. For example, a function with the prefix hostfxr is very likely to be a necessary function, while a function with the prefix coreclr is very likely to be a functional function.
[0065] S13 calls the corresponding function for verification according to the preset calling rules and the address information in the grouping symbol subtable; and takes the successfully verified function as a necessary function.
[0066] The preset calling rules described in this embodiment include: 1. Prioritize calling the functions in the necessary function group for verification. It is easy to understand that the functions in the necessary function group are the necessary functions for .NET to run under the first operating system (such as the Linux operating system) during runtime, so the functions in the necessary function group are limited to calling. 2. Based on the number of times each grouping symbol subtable is successfully loaded in different environments, multiple grouping symbol subtables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and they are loaded in order from high to low until they are successfully loaded. Generally speaking, the more times it is successfully loaded, the more it can create an operating environment for Dotnet core in various operating environments, that is, its compatibility is higher. Preferably, the number of times each grouping symbol subtable is successfully loaded in different environments is obtained based on historical data statistics, or is obtained by multiple tests in advance. When each necessary function in the grouping symbol subtable is loaded successfully, a value (for example, true) will be returned. Accordingly, if the return value is received, it means that the grouping symbol subtable has passed the verification, that is, the grouping symbol subtable has been loaded successfully.
[0067] In this embodiment, the symbol table is grouped and called for trial operation according to a pre-set priority. Compared with the method of directly calling randomly or blindly calling the trial operation one by one, the trial and error cost and probability are greatly reduced. Therefore, it is possible to find multiple necessary functions for building a first operating system (such as a Linux operating system) for the .NET runtime more quickly. In the above manner, this embodiment selects hostfxr_initialize_for_runtime_config and hostfxr_get_runtime_delegate in the hostfxr dynamic library as necessary functions for the .NET runtime to run under Linux. Among them, the hostfxr_initialize_for_runtime_config function is used to initialize the host context of the .NET runtime environment. This function prepares to initialize the .NET runtime according to the provided runtime configuration file. The hostfxr_get_runtime_delegate function is used to obtain the delegate of a specific .NET runtime function. Through this function, access rights to various functions in the .NET runtime can be obtained, such as loading assemblies, obtaining type information, etc.
[0068] Exemplarily, the above two functions are the minimum parameter configurations for the .NET runtime to run under the Linux system.
[0069] S2 encapsulates the C++ interface into a C# interface under Linux; when encapsulating the interface, the data type of CAD under Linux is converted into the data type of CAD under .NET.
[0070] Through step S1, .NET can be successfully run under the first operating system (such as Linux operating system) during runtime, so that the CAD platform under the first operating system can call the .NET application plug-in. However, to carry out secondary development, it is not only necessary to call the .NET plug-in, but also to use a programming language. The popular programming language of the CAD platform is C#, which is an object-oriented programming language developed by Microsoft. Compared with C++, it is less difficult and easier to use. However, C# is a Windows programming language and is not directly supported under the first operating system such as Linux system. And C++ is a cross-platform language, which can be well supported in the first operating system such as Linux. Therefore, in this step, it is necessary to encapsulate the C++ interface as a C# interface under the first operating system such as LinuxLinux, so that the user can call the .NET application plug-in of the CAD under the first operating system such as Linux through C#. In addition, the data types in C++ and C# languages are expressed in different forms, and since the present invention is directed to the secondary development of CAD, some special data types of the CAD platform will also be involved, as shown in Table 2.
[0071] Table 2 Examples of data type rules in C# / C++ / CAD environments As shown in the table above, even for the same data type, the rules in the three different environments are different. For example, a data type is sbyte in C#, but char in C++ and CAD. Another example is that a data type is int in C# and C++, but Int32 in CAD. The above table is only an example. In actual applications, data types are more complex and can be combined with each other.
[0072] The main steps to encapsulate a C++ interface into a C# interface under Linux and other first-class operating systems include: preparing a C++ dynamic library, exporting C++ functions using extern "C", declaring function prototypes in C# using the DllImport feature, performing data type conversion, encapsulating complex data types, processing callback functions, and testing and debugging. Through these steps, seamless integration between C++ and C# can be achieved. The specific steps include: 1. Prepare C++ dynamic library. First, compile the C++ code into a dynamic link library (.so file). The dynamic library contains the C++ interface that needs to be encapsulated.
[0073] 2. Use extern "C" to export C++ functions. In order to make C++ functions callable from C#, you need to use the extern "C" modifier to export these functions to avoid the C++ name mangling problem.
[0074] / / C++ code exampleextern "C" { __declspec(dllexport) int Add(int a, int b); __declspec(dllexport) void PrintHello();} 3. Use the DllImport attribute in C#. In C#, use the DllImport attribute to declare the prototype of the C++ function and specify the path and calling convention of the dynamic library.
[0075] using System.Runtime.InteropServices; public class NativeMethods { [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)] public static extern int Add(int a, int b); [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)] public static extern void PrintHello();} 4. Data type conversion.
[0076] In C#, you need to perform appropriate conversions based on the data type of the C++ interface. Common data type conversions include: Basic data types: such as int, float, double, bool, etc. can be mapped directly.
[0077] Pointer type: Use IntPtr or HandleRef to handle.
[0078] String type: Use Marshal.PtrToStringAnsi or Marshal.PtrToStringUni to convert char* or wchar_t*.
[0079] Complex data types, such as structures and classes, require the use of StructLayout and FieldOffset features in C# to define the memory layout.
[0080] 5. Encapsulation of complex data types.
[0081] If the C++ interface involves complex data types (such as structures or classes), corresponding encapsulation and conversion are required in C#.
[0082] Example: Encapsulating a Structure / / C++ code example struct Point { int x; int y;}; extern "C" { __declspec(dllexport) void SetPoint(Point p); __declspec(dllexport) Point GetPoint();} / / C# code example using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)]public struct Point { public int x; public int y;} public class NativeMethods { [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)] public static extern void SetPoint(Point p); [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)] public static extern Point GetPoint();} 6. Process the callback function.
[0083] If the C++ interface needs to use a callback function, it can be encapsulated in C# through a delegate.
[0084] Example: Callback Function / / C++ code example typedef void (*CallbackFunction)(int); extern "C" { __declspec(dllexport) void RegisterCallback(CallbackFunctioncallback);} / / C# code example using System; using System.Runtime.InteropServices; public class NativeMethods { public delegate void CallbackFunction(int value); [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)] public static extern void RegisterCallback(CallbackFunctioncallback);} 7. Testing and debugging.
[0085] After encapsulation is completed, test and debug to ensure that the C# code can correctly call the C++ interface and that there are no problems with data transfer and conversion.
[0086] In the process of encapsulating a C++ interface into a C# interface, the data type conversion from C++ to C# is involved. The above conversion process can be understood as a general data type conversion process.
[0087] Since the purpose of the present invention is to use .NET plug-in and C# to perform secondary development on CAD in a first operating system such as Linux or a first operating environment, in addition to the conversion of data types from C++ to C#, it is more important to convert the data type of CAD in the first operating system such as Linux into the data type of CAD in .NET (for example, GCAD data type), and the specific steps include: S21 obtains the data type rules of CAD under the first operating system and the data type rules of CAD under .NET.
[0088] like Figure 5 As shown, the data of the CAD platform in the C++ operating environment: "bool operator ==(const GcGeMatrix3d&mat) const; bool operator !=(const GcGeMatrix3d&mat) const;” like Figure 6 As shown, the same data in the CAD platform under the C# operating environment is: “public bool IsEqualTo(Matrix3d mat); public bool IsEqualTo(Matrix3d mat, Tolerance tolerance);".
[0089] Due to the diversity of data types, many data types have their own unique data type rules, so the data type rules of the corresponding data types in two language environments must be obtained to convert between the two. In addition, data type rules are not universal, and the rules of different data types are also different.
[0090] S22 constructs a conversion grammar rule for converting the data type of CAD in the first operating system or the first operating environment into the data type of CAD in .NET according to the acquired data type rule.
[0091] The conversion between data types requires corresponding conversion grammar rules, such as the data of the CAD platform in the C++ operating environment to the data of the CAD platform in the C# operating environment. The conversion between different data types requires the establishment of conversion grammar rules.
[0092] Continuing with the previous example, Figure 7 is an example of a transformation grammar rule.
[0093] If it is expressed as "GcGeMatrix3d::operator *" in the C++ operating environment (where "GcGeMatrix3d:" is the class name and ":operator *" is a specific presentation format), it will be converted to "times" in the C# operating environment.
[0094] For example, if it is expressed as "GcGeMatrix3d::operator ==" in the C++ operating environment, it will be converted to "equal" in the C# operating environment.
[0095] S23 uses the conversion grammar rule to batch convert the CAD data types in the first operating system or the first operating environment into the CAD data types in .NET.
[0096] Due to the large number of data types, if the conversion is done manually, the workload is very huge. Therefore, in the present invention, the data types of CAD under the first operating system such as Linux are automatically converted in batches to the data types of CAD under .NET by writing the conversion grammar rules into scripts. The so-called script is a code or instruction sequence for automated tasks. Scripts are usually used to execute a series of predefined operations without manual intervention.
[0097] After the packaging work is completed, the user can call the function library of the first operating system, such as the Linux system, through the C# interface, so as to carry out secondary development of CAD simply and quickly.
[0098] like Figure 8 As shown, the C++ interface describing the data type is encapsulated to obtain the C# interface Curve2d.cs.
[0099] Embodiment 2: The present invention also provides a system for performing CAD secondary development based on .NET runtime, comprising: A runtime environment building module, used for dynamically loading dynamic libraries and calling necessary functions of the .NET runtime in the hostfxr dynamic library for running in the first operating system or the first runtime environment, building a runtime environment for the .NET runtime in the first operating system or the first runtime environment, so that the .NET program can run in the first operating system or the first runtime environment; The interface encapsulation module is used to encapsulate the C++ interface into a C# interface in the first operating system or the first operating environment; when performing interface encapsulation, the data type of CAD in the first operating system or the first operating environment is converted into the data type of CAD in .NET.
[0100] Preferably, the above-mentioned operating environment building module is specifically used for: parsing several dynamic library files to obtain a symbol table in the dynamic library files; the symbol table includes the name and address information of each function; grouping the functions in the symbol table according to preset grouping rules to obtain several grouping sub-tables; calling the corresponding function according to the preset calling rules and based on the address information in the grouping symbol sub-table for verification; and using the successfully verified function as a necessary function.
[0101] In some embodiments, the preset grouping rules include: grouping functions with the same prefix, originating from the same dynamic library file and belonging to the same initialization function module into one group; marking the function group into a necessary function group and a functional function group according to function attributes.
[0102] In some embodiments, the above-mentioned preset calling rules include: giving priority to calling functions in the necessary function group for verification; more preferably, based on the number of times each grouping symbol sub-table is successfully loaded under different environments, multiple grouping symbol sub-tables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and they are loaded in order from high to low until they are successfully loaded.
[0103] Example 3: See Fig. 9 The present invention provides a method for realizing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which comprises the steps of: S101, in a first operating environment, dynamically load Dotnet core to match to a second operating environment. In some embodiments, the first operating environment is a C++ operating environment, such as a Linux operating system; the second operating environment is a C# operating environment or a Dotnet environment (i.e., a .NET environment).
[0104] S102, in the second operating environment, batch encapsulate the C++ interfaces to convert them into C# interfaces in the second operating environment, so that users can arbitrarily call the C# interface corresponding to any C++ interface to achieve secondary development.
[0105] In some embodiments, the above step S101 specifically includes: S201, loading the dynamic library, and obtaining the symbol table of each call object in the dynamic library, the symbol table including the attribute information and address information of each call object; the call object is used to build a corresponding second operating environment for Dotnet core. In some embodiments, the step of obtaining the symbol table of each call object in the dynamic library specifically includes: filtering out the target so file from the dynamic library according to the preset filtering rules, and then generating a corresponding symbol table based on the target so file. Among them, the target so file includes the initialization function module with the highest number of successful loads under different operating environments. In some embodiments, the dynamic library is the hostfxr dynamic library provided by Microsoft (the hostfxr library exposes functions for hosting the .NET runtime).
[0106] S202, grouping the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables. In some embodiments, the preset grouping rule includes: screening out a plurality of necessary functions according to attribute information, and then grouping the necessary functions from the same So file and the same initialization function module into a group, see Table 1 above. The attribute information includes the definition of each function (including: name, parameters, etc.).
[0107] S203, according to the preset calling rules, and according to the address information in the grouping symbol subtable, the corresponding calling object is called for verification. If the verification passes, the calling object (ie, multiple necessary functions) for building the second operating environment for Dotnet core is obtained.
[0108] In some embodiments, the preset call rule includes: based on the number of times each grouping symbol subtable is successfully loaded under different operating environments, multiple grouping symbol subtables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and the trial runs are called in order from high to low priority. Generally speaking, the more successful loadings, the more capable it is to create an operating environment for Dotnet core in various operating environments, that is, the higher its compatibility.
[0109] Preferably, the number of times each grouping symbol sub-table is successfully loaded under different environments is obtained based on historical data statistics, or is obtained by performing multiple tests in advance. Specifically, the testing process is in accordance with the above steps S201 to S203.
[0110] In this embodiment, the symbol table is grouped and called for trial operation according to a preset priority. Compared with the method of directly calling randomly or blindly calling the trial operation one by one, the trial and error cost and probability are greatly reduced. Therefore, multiple necessary functions for building a second operating environment for Dotnet core can be found more quickly.
[0111] In some embodiments, the above step S102 specifically includes step: S301, respectively obtaining the first data type rule under the first operating environment, the second data type rule under the second operating environment, and the third data type rule under the third operating environment.
[0112] As shown in Table 2 above, even for the same data type, the rules in the three different environments are different. For example, a data type is sbyte in the Windows environment, but char in the Linux and GCAD environments. For another example, a data type is int in the Windows environment and the Linux environment, but Int32 in the GCAD environment. The above table is only an example. In actual applications, data types are more complex and can be combined with each other. In some embodiments, the first operating environment refers to the C++ operating environment, the second operating environment refers to the C# operating environment, and the third operating environment refers to the GCAD platform environment.
[0113] S302, constructing a conversion grammar rule for converting the first data type in the first operating environment and the third data type in the third operating environment to the second data type in the second operating environment. In some embodiments, the conversion grammar rule for converting the C++ data type (i.e., the first data type) and the GCAD data type (i.e., the third data type) to the C# data type (i.e., the second data type) needs to take into account the differences in data types in the three environments, as shown in Table 2 above. That is, it is necessary to consider integrating the data type rules in the three environments.
[0114] In some embodiments, the step of constructing the conversion grammar rule specifically includes: constructing a mapping table between the first data type and the second data type and / or the third data type, and then converting the second data type and / or the third data type into the first data type based on the mapping relationship.
[0115] For example, in the C# runtime environment, if the first data type in the C++ runtime environment conforms to a predetermined syntax rule (e.g., class name: specific presentation form in the C++ environment), it is converted to the first data type. Figure 7 If it is expressed as "GcGeMatrix3d::operator *" in the C++ operating environment (where "GcGeMatrix3d:" is the class name and ":operator *" is a specific presentation format), it will be converted to "times" in the C# operating environment.
[0116] For example, if it is expressed as "GcGeMatrix3d::operator ==" in the C++ operating environment, it will be converted to "equal" in the C# operating environment.
[0117] For example, see Figure 5 , before conversion: Data of GCAD platform in C++ operating environment: "bool operator == (const GcGeMatrix3d&mat) const; bool operator != (const GcGeMatrix3d&mat) const;” After conversion, we can get the data of GCAD platform in C# running environment, see Figure 8 : “public bool IsEqualTo(Matrix3d mat); public bool IsEqualTo(Matrix3d mat, Tolerance tolerance);".
[0118] S303: Based on the conversion grammar rules, the C++ interfaces are encapsulated in batches to be converted into C# interfaces in the second operating environment, so that the user can arbitrarily call the C# interface corresponding to any C++ interface. Figure 8 , the C++ interface on the left is converted through its corresponding conversion syntax rules to obtain the C# interface on the right. For example, dbcurve.h describing the data type is converted (or encapsulated) through its corresponding conversion syntax rule dbcurve.i to obtain Curve2d.cs.
[0119] Example 4: See Fig.12 The present invention also provides a system for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which includes: An operating environment creation device is used to dynamically load a second operating environment in which Dotnet core can run under the first operating environment; The interface encapsulation device is used to encapsulate C++ interfaces in batches under the second operating environment to convert them into C# interfaces under the second operating environment, so that users can arbitrarily call the C# interface corresponding to any C++ interface.
[0120] Example 5: See Fig.10 The present invention also provides a method for constructing a running environment for a C# interface in dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which comprises the steps of: S201, load the dynamic library, and obtain the symbol table of each call object in the dynamic library, wherein the symbol table includes attribute information and address information of each call object; the call object is used to build a corresponding second operating environment for Dotnet core.
[0121] In some embodiments, the step of obtaining the symbol table of each calling object in the dynamic library specifically includes: filtering out the target so file from the dynamic library according to a preset filtering rule, and then obtaining the symbol table of the target so file.
[0122] In some embodiments, the loads the hostfxr dynamic library provided by Microsoft (the hostfxr library exposes functions for hosting the .NET runtime).
[0123] S202, grouping the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables.
[0124] In some embodiments, the preset grouping rule includes: screening out a plurality of necessary functions according to the attribute information, and then grouping the necessary functions from the same so file and the same initialization function module into one group.
[0125] S203, according to the preset calling rule and the address information in the grouping symbol sub-table, the corresponding calling object is called for verification to obtain a target calling object.
[0126] In some embodiments, the preset calling rule includes: based on the number of times each grouping symbol sub-table is successfully loaded in different environments, multiple grouping symbol sub-tables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and the trial runs are called in order from high to low priority until the loading is successful (that is, the verification is passed). Specifically, each grouping symbol sub-table corresponds to multiple necessary functions, and when each necessary function in the grouping symbol sub-table is successfully loaded, a value (for example, true) will be returned. Accordingly, if the return value is received, it means that the grouping symbol sub-table has passed the verification, that is, the grouping symbol sub-table has been successfully loaded.
[0127] Preferably, the number of times each grouping symbol sub-table is successfully loaded under different environments is obtained based on historical data statistics, or is obtained by performing multiple tests in advance.
[0128] Embodiment 6: The present invention also provides a device for constructing a running environment for a C# interface in dotnet secondary development based on a Linux GCAD platform for implementing a .NET7 runtime, which includes: The first loading module is used to load the dynamic library and obtain the symbol table of each calling object in the dynamic library, wherein the symbol table includes attribute information and address information of each calling object; the calling object is used to build a corresponding second operating environment for Dotnet core; A grouping module, used for grouping the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables; The calling verification module is used to call the corresponding calling object for verification according to the preset calling rules and the address information in the symbol subtable to obtain the target calling object.
[0129] Example 7: See Fig.11 The present invention also provides an interface encapsulation method for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which comprises the steps of: S301, respectively obtaining a first data type rule in a first operating environment, a second data type rule in a second operating environment, and a third data type rule in a third operating environment; S302, constructing a conversion grammar rule of the second data type rule in the second operating environment and the third data type rule in the third operating environment; S303: Batch encapsulate the C++ interfaces based on the conversion grammar rules to convert them into C# interfaces under the second operating environment, so that the user can arbitrarily call the C# interface corresponding to any C++ interface.
[0130] Embodiment 8: The present invention also provides an interface encapsulation device for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which comprises: A data acquisition module, used to respectively acquire a first data type rule under a first operating environment, a second data type rule under a second operating environment, and a third data type rule under a third operating environment; A grammar construction module, used to construct a conversion grammar rule of the second data type rule under the second operating environment and the third data type rule under the third operating environment; The encapsulation module is used to encapsulate the C++ interfaces in batches based on the conversion grammar rules to convert them into C# interfaces under the second operating environment, so that users can arbitrarily call the C# interface corresponding to any C++ interface.
[0131] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0132] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a computer terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0133] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A method for CAD secondary development based on .NET runtime, characterized in that include: In a first operating system or a first operating environment, dynamically load a hostfxr dynamic library, and call necessary functions in the hostfxr dynamic library for the .NET runtime to run in the first operating system or the first operating environment, so as to build a second operating environment in the first operating system or the first operating environment for the .NET runtime, so that the .NET program can run in the first operating system or the first operating environment; In the first operating system or the first operating environment, the C++ interfaces are batch packaged into C# interfaces; and when batch packaging is performed, the CAD data type is converted into the CAD data type under .NET; The step of calling the necessary functions of the .NET runtime running in the first operating system or the first operating environment includes: Parsing several dynamic library files in the dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; Grouping the functions in the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables; According to the preset calling rules, the corresponding function is called for verification according to the address information in the grouping symbol subtable; Make the function that verifies success a required function.
2. The method for CAD secondary development based on .NET runtime according to claim 1, characterized in that: The first operating system is a Linux operating system; the first operating environment is a C++ operating environment; And / or, the second operating environment is an operating environment of a C# interface, or a .NET environment.
3. The method for CAD secondary development based on .NET runtime according to claim 1, characterized in that: The preset grouping rules include: Group functions with the same prefix, from the same dynamic library file and belonging to the same initialization function module into one group; Function groups are marked as necessary function groups and functional function groups according to function attributes.
4. The method for CAD secondary development based on .NET runtime according to claim 3, characterized in that: The preset calling rules include: Prioritize calling functions in the necessary function group for verification; Based on the number of times each grouping symbol sub-table is successfully loaded in different environments, multiple grouping symbol sub-tables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and they are loaded in order from high to low until they are successfully loaded.
5. The method for CAD secondary development based on .NET runtime according to claim 1, characterized in that: The step of converting the data type of CAD in the first operating system or the first operating environment into the data type of CAD in .NET includes: Obtaining a data type rule of CAD in the first operating system or the first operating environment and a data type rule of CAD in .NET; Constructing a conversion grammar rule for converting the data type of CAD in the first operating system or the first operating environment into the data type of CAD in .NET according to the acquired data type rule; The data types of CAD in the first operating system or the first operating environment are batch converted into the data types of CAD in .NET by using the conversion grammar rules.
6. The method for CAD secondary development based on .NET runtime according to claim 5, characterized in that: The data types of CAD in the first operating system or the first operating environment are automatically converted in batches into the data types of CAD in .NET by writing the conversion grammar rules into scripts.
7. A cross-operating system .NET runtime calling method, characterized in that: Includes steps: Dynamically load the hostfxr dynamic library, and parse several dynamic library files in the hostfxr dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; The functions in the symbol table are grouped according to a preset grouping rule to obtain a plurality of grouping sub-tables; wherein the preset grouping rule includes: grouping functions having the same prefix, originating from the same dynamic library file and belonging to the same initialization function module into one group; marking the function group into a necessary function group and a functional function group according to function attributes; According to the preset calling rules, and according to the address information in the grouping symbol subtable, the corresponding function is called for verification; wherein the preset calling rules include: preferentially calling the functions in the necessary function group for verification; The successfully verified function is regarded as a necessary function, and the necessary function is called.
8. The cross-operating system .NET runtime calling method according to claim 7, characterized in that: The preset calling rules also include: based on the number of times each grouping symbol sub-table is successfully loaded in different environments, multiple grouping symbol sub-tables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and the sub-tables are loaded in order from high to low until they are successfully loaded.
9. A system for CAD secondary development based on .NET runtime, characterized in that include: An operating environment building module is used to dynamically load a hostfxr dynamic library in a first operating system or a first operating environment, and call necessary functions of the .NET runtime in the first operating system or the first operating environment in the hostfxr dynamic library, so as to build a second operating environment in the first operating system or the first operating environment for the .NET runtime, so that the .NET program can be run in the first operating system or the first operating environment; The interface encapsulation module is used to encapsulate the C++ interface into a C# interface in the first operating system or the first operating environment; when performing interface encapsulation, the data type of CAD in the first operating system or the first operating environment is converted into the data type of CAD in .NET.
10. A system for CAD secondary development based on .NET runtime according to claim 9, characterized in that The operating environment building module is specifically used to parse several dynamic library files in the dynamic library to obtain a symbol table in the dynamic library file; the symbol table includes the name and address information of each function; and the functions in the symbol table are grouped according to preset grouping rules to obtain several grouping sub-tables; then according to the preset calling rules, and according to the address information in the grouping symbol sub-table, the corresponding function is called for verification, and the function that has successfully been verified is used as a necessary function.
Citation Information
Patent Citations
Service deployment method, device and equipment and readable storage medium
CN115617346A
Industrial configuration software secondary development method
CN103309718A
Automatic and quick processing method for information of I / O (Input / Output) points on the basis of AutoCAD (Autodesk Computer Aided Design)
CN106951577A
Method and device for running second system application in first system, equipment and medium
CN111984263A
Secondary development file execution method and device and storage medium
CN113885963A