Cross-operating system .NET runtime calling method, CAD secondary development method and system

By dynamically loading hostfxr dynamic library and data type conversion, the problem that the .NET platform CAD application plug-in cannot be called directly under Linux is solved, and efficient cross-platform CAD secondary development is realized, supporting multi-system operation and rapid updates, and is suitable for mechanical design, architectural design and other fields.

CN119759344BActive Publication Date: 2025-08-15SUZHOU CAD SOFTWARE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411896497.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2024-05-30
Filing Date
2024-12-20
Publication Date
2025-08-15
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

Under the Linux operating system, CAD application plug-ins developed based on the .NET platform cannot be called directly, and existing cross-platform implementation methods such as mono run slowly, which cannot meet the needs of developers, especially due to the difference in data types between C# and C++, the cross-platform secondary development is difficult.

Method used

By dynamically loading the hostfxr dynamic library, finding and calling the necessary functions in Linux during the .NET runtime, building the .NET running environment, and encapsulating the C++ interface into a C# interface, and performing data type conversion to realize cross-platform CAD secondary development.

Benefits of technology

It realizes efficient operation of .NET programs under Linux, supports high-performance CAD secondary development, provides cross-platform C# interface, improves operation efficiency and update speed, supports multi-CPU architecture and multi-system operation, and is suitable for mechanical design, architectural design and other fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759344B_ABST
    Figure CN119759344B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and more particularly, to a method and system for performing CAD secondary development based on the .NET runtime. The method comprises: dynamically loading a dynamic library and calling necessary functions of the .NET runtime running under Linux within a first operating system or a first operating environment to construct a secondary operating environment for the .NET runtime; encapsulating a C++ interface into a C# interface within the first operating system or the first operating environment; and, during the interface encapsulation, converting CAD data types within the first operating system or the first operating environment into CAD data types within the .NET runtime. The present invention enables .NET programs to run under Linux and convert data types through interface encapsulation, thereby achieving cross-platform secondary development of CAD. Accordingly, the present invention also provides a cross-operating system .NET runtime calling method.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Priority application

[0002] This application claims priority to the Chinese invention patent application [Application Number: 202410692289.1] [Invention Title: 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

[0003] 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 the .NET runtime. Background Art

[0004] Domestic CAD secondary development is still in its exploratory phase, and the secondary development ecosystem, particularly the .NET ecosystem, is immature. For example, numerous .NET application plug-ins exist for CAD platforms. However, as a development platform for the Windows operating system, application plug-ins developed using .NET cannot be directly called on other operating systems, such as Linux. Therefore, running programs developed on the .NET platform on other operating systems like Linux has become a pressing issue for CAD secondary development in these environments.

[0005] Currently, the .NET platform supports multiple languages and editors, providing an environment for many open source enthusiasts. This frees .NET programs from being limited to the Windows platform. Through its built-in C# compiler and various class libraries, .NET programs can run on operating systems such as Windows, Linux, and Solaris. For example, Mono is an open source cross-platform .NET implementation on Linux, allowing developers to run and develop applications based on the .NET Framework. However, its slow performance and slow update rate make it unable to meet the needs of developers.

[0006] Prior art Chinese patent application CN202211330751.0 discloses a service deployment method, apparatus, device and readable storage medium. In this method, 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.

[0007] In the above-mentioned 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.

[0008] Furthermore, .NET is developed on the Windows platform using the C# language. Other operating systems like Linux are developed using the C++ language, which has different data types. Furthermore, CAD platforms under Linux and other operating systems also have different data types than those under .NET. This data type difference is a significant obstacle to cross-platform secondary development. Summary of the Invention

[0009] 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 shortcomings in the existing technology, enables .NET programs to run under Linux and convert data types through interface encapsulation, thereby realizing cross-platform secondary development of CAD.

[0010] In order to solve the above-mentioned technical problems, the present invention specifically adopts the following technical solutions:

[0011] A first aspect of the present invention is to provide a method for CAD secondary development based on a .NET runtime, comprising:

[0012] In a first operating system or a first operating environment, dynamically loading a hostfxr dynamic library and calling necessary functions in the hostfxr dynamic library for the .NET runtime to run in the first operating system or the first operating environment, thereby building a second operating environment for the .NET runtime in the first operating system or the first operating environment, thereby enabling the .NET program to run in the first operating system or the first operating environment;

[0013] 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;

[0014] The step of calling the necessary functions of the .NET runtime running in the first operating system or the first operating environment includes:

[0015] Parsing a plurality of 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;

[0016] Grouping the functions in the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables;

[0017] According to the preset calling rules, the corresponding function is called for verification according to the address information in the grouping symbol subtable;

[0018] The function that verifies success is considered a required function.

[0019] Preferably, the first operating system is a Linux operating system.

[0020] Preferably, the first operating environment is a C++ operating environment.

[0021] Preferably, the second operating environment is a C# interface operating environment or a .NET environment.

[0022] Preferably, 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 groups into necessary function groups and functional function groups according to function attributes.

[0023] Preferably, the preset calling rule includes: preferentially calling functions in a necessary function group for verification.

[0024] More preferably, the preset calling rules also include: prioritizing multiple grouped symbol subtables based on the number of times each grouped symbol subtable 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 successful loading.

[0025] Preferably, the step of converting the CAD data type in the first operating system or the first operating environment to the CAD data type in .NET includes:

[0026] Obtaining a data type rule for CAD in the first operating system or the first operating environment and a data type rule for CAD in .NET;

[0027] Constructing a conversion grammar rule for converting the data type of CAD in the first operating system or the first operating environment to the data type of CAD in .NET according to the acquired data type rule;

[0028] The conversion grammar rules are used to batch convert the CAD data types in the first operating system or the first operating environment into the CAD data types in .NET.

[0029] 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.

[0030] A second aspect of the present invention is to provide a cross-operating system .NET runtime calling method, comprising the steps of:

[0031] 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;

[0032] The functions in the symbol table are grouped according to a preset grouping rule to obtain a plurality of grouped symbol 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;

[0033] According to the preset calling rules, and based on 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;

[0034] The successfully verified function is regarded as a necessary function, and the necessary function is called.

[0035] Preferably, the preset calling rules also include: prioritizing multiple grouped symbol subtables based on the number of times each grouped symbol subtable 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 successful loading.

[0036] A third aspect of the present invention is to provide a system for CAD secondary development based on a .NET runtime, comprising:

[0037] 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 in the hostfxr dynamic library for the .NET runtime to run in the first operating system or the first operating environment, thereby building 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;

[0038] 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 CAD data type in the first operating system or the first operating environment is converted into the CAD data type in .NET.

[0039] 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 grouped symbol sub-tables; then, according to the preset calling rules, and based on the address information in the grouped symbol sub-table, the corresponding function is called for verification, and the successfully verified function is used as a necessary function.

[0040] Beneficial effects: 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 enable .NET to run on Linux. It uses a built-in C# language compiler, CLR runtime and various class libraries to enable .NET applications to run on different operating systems such as Windows, Linux, Solaris, etc.), it has many problems such as slow operation and slow update speed. In addition, the CAD platform has its own professional characteristics, which makes it impossible for users to conveniently and quickly carry out secondary development of CAD .NET plug-ins 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 enable secondary development of .NET plug-ins in CAD under other operating systems, such as the Linux operating system. For example, by implementing cross-operating system .NET runtime calls, the .NET runtime (preferably .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 users.

[0041] The present invention dynamically loads a .NET runtime environment within a C++ environment (e.g., an operating system like Linux). Specifically, it locates and loads the necessary functions (e.g., initialization-related functions) required to provide the .NET runtime environment within a dynamic library, thereby building the .NET runtime environment and enabling the smooth operation of the subsequently encapsulated C# interface. Furthermore, dedicated conversion grammar rules are constructed to enable the conversion of CAD data types between two platforms (e.g., the DotNet platform and the CAD platform under the Linux operating system), thereby enabling batch C++ interface encapsulation and enabling users to freely call the .NET runtime through the C# interface for secondary development.

[0042] The present invention also includes the following benefits:

[0043] High operating efficiency. Based on the high-performance desktop .NET7 environment provided by Microsoft, CAD runs more efficiently on the Linux operating system.

[0044] 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.

[0045] GUI systems such as Avalonia can be used to support the Linux GCAD platform, but MONO does not support it.

[0046] It supports multiple CPU architectures and multiple systems, and 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.

[0047] The present invention can be widely used in mechanical design, architectural design, industrial design and other fields, can provide strong support to secondary development manufacturers, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the embodiments or the description of the prior art. In all drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the various elements or parts are 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 inventive work.

[0049] Figure 1 This is a flow chart of Embodiment 1 of the present invention;

[0050] Figure 2 This is a schematic diagram of some so files in the dynamic library;

[0051] Figure 3 This is a diagram of the names and addresses of some necessary functions in the symbol table;

[0052] Figure 4 This is a diagram of the names and addresses of some optional functions (functional functions) in the symbol table;

[0053] Figure 5 This is a schematic diagram of the key data types of CAD in the C++ environment;

[0054] Figure 6 for Figure 5 The key data types shown are converted into the key data types diagram of CAD in C# environment;

[0055] 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;

[0056] Figure 8 This is a partial screenshot of the C# interface obtained by batch encapsulating the C++ interface using the invented encapsulation method;

[0057] Figure 9 This is a flowchart of embodiment 3 of the present invention;

[0058] Figure 10 This is a flowchart of Embodiment 5 of the present invention;

[0059] Figure 11 This is a flowchart of Embodiment 7 of the present invention;

[0060] Figure 12 This is a system framework diagram of embodiment 4 of the present invention. DETAILED DESCRIPTION

[0061] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 efforts are within the scope of protection of the present invention.

[0062] As used herein, suffixes such as "module," "component," or "unit" are used solely to facilitate the description of the present invention and do not inherently have specific meanings. Therefore, "module," "component," or "unit" may be used interchangeably. Terms such as "upper," "lower," "inner," "outer," "front," "rear," "one end," and "the other end" used herein to indicate positions or locations are based on those shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and are therefore not to be construed as limiting the present invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. As used herein, unless otherwise expressly specified or limited, terms such as "mounted," "disposed," and "connected" are to be understood broadly. For example, "connected" may refer to a fixed connection, a removable connection, or an integral connection; it may refer to a mechanical connection, a direct connection, an indirect connection through an intermediary, or internal communication between two components. Those skilled in the art will understand the specific meanings of these terms in the present invention. Herein, "and / or" includes any and all combinations of one or more of the listed items. Herein, "plurality" means two or more, that is, it includes two, three, four, five, etc.

[0063] Definition of noun:

[0064] "Linux" is a free and open-source Unix-like operating system. It is released under the GNU General Public License and is freely available and usable. The Linux operating system kernel was first released by Linus Torvalds in 1991.

[0065] "Windows": is an operating system developed by Microsoft. It was first released in 1985 and has become one of the most widely used desktop operating systems in the world.

[0066] "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 C that adds object-oriented programming (OOP) features.

[0067] "C#": is an object-oriented programming language developed by Microsoft. It is one of the main languages of the .NET Framework.

[0068] .NET: A software development platform developed by Microsoft to simplify application development, deployment, and management. Originally released in 2002, it is now an open-source platform that supports multiple programming languages, such as C#.

[0069] ".NET runtime": One of the core components of the .NET framework, responsible for executing .NET applications.

[0070] ".Net Core": Using the cross-platform Common Intermediate Language (CIL) technology, the compiler converts code written in a 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.

[0071] 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 on both Windows systems (such as AutoCAD) and Linux systems (such as GstarCAD).

[0072] "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 evolving and improving. The latest Dotnet Core version has the advantages of higher performance, smaller memory footprint, 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.

[0073] "Required functions" refer to the most basic functions required to build the runtime environment for Dotnet Core, such as initialization-related functions in dynamic libraries. Of course, in addition to these required functions (i.e., call objects), dynamic libraries also include optional functions that users can select based on their actual needs.

[0074] “Secondary development” refers to further development and customization of existing software or platforms (e.g., the CAD platform in this invention) to meet specific needs or expand existing functionality.

[0075] An "initialization module" is a function package used to implement initialization, including multiple essential functions. Typically, a software or application will have different initialization modes in different operating environments (or operating systems). Accordingly, an initialization module corresponds to each initialization mode. A single ..i file typically contains multiple initialization modules.

[0076] "Runtime Environment" refers to the various conditions required for the operation of software or various plug-ins, including both the hardware and software environments. Examples include the Linux operating system (also the C++ runtime environment), the Windows operating system, and DotNet (the C# runtime environment). It can also be a dedicated software platform developed by the software developer, such as the GCAD platform, or an application. The C++ runtime environment includes various operating systems, such as the Linux operating system.

[0077] "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 the successful operation is finally found, that is, the operating environment of Dotnet core is obtained.

[0078] hostfxr is the abbreviation of ".NET Host FX Resolver", where "FX" stands for "Framework".

[0079] As mentioned previously, since most .NET application plug-ins in CAD are developed on the .NET development platform for the Windows operating system, many of these .NET application plug-ins cannot be directly called or loaded in other operating systems (such as Linux). To enable the calling of .NET application plug-ins in CAD in other operating systems, it is necessary to build the required .NET runtime environment in the corresponding operating system, thereby enabling the calling of the .NET runtime in that operating system and, in turn, enabling secondary development of CAD in that operating system.

[0080] 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.

[0081] Take CAD secondary development based on the .NET runtime under the Linux operating system as an example: first, dynamically load the hostfxr dynamic library of the Windows operating system under the Linux operating system (i.e., the first operating environment), and find the necessary functions required for the .NET runtime to run under the Linux operating system, so as to build the environment required by the .NET runtime, i.e., the .NET environment or .NET platform (i.e., the second operating environment); then, under the Linux operating system, convert the data types of the CAD platform (i.e., the third operating environment) and the data types of the .NET platform into data types under the Linux operating system.

[0082] The following describes it in detail with reference to specific embodiments.

[0083] Example 1: Figure 1 As shown, the present invention provides a method for CAD secondary development based on .NET runtime, the specific steps of which include:

[0084] 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.

[0085] .NET programs developed on the .NET platform include applications and plug-ins, and generally only run under Windows. To run a .NET program under another operating system, such as Linux, you need to establish a runtime environment for it—in other words, build a .NET environment (or .NET platform). The .NET runtime, a core component of the .NET framework, is responsible for executing .NET applications and is essential for running .NET programs. Therefore, in this embodiment, in order to call a .NET application plug-in on a CAD platform running a first operating system (such as Linux) other than Windows (referred to as the second operating system), the .NET runtime must first be running under the first operating system (such as Linux).

[0086] Taking the Linux operating system as an example, the first step is to load Microsoft's hostfxr dynamic library. The library then calls the necessary functions for the .NET runtime to run on Linux, thereby establishing the secondary runtime environment for the .NET runtime on Linux—the .NET environment. hostfxr is a key dynamic library (DLL) in the .NET platform, primarily responsible for hosting the runtime environment for .NET applications. The hostfxr dynamic library is a relatively complex library, containing multiple functions for configuring, loading, and managing the runtime environment for .NET applications. Because the internal implementation of hostfxr is closed source (although the .NET runtime itself is open source), the exact number and names of these functions are not fully public. This means that among the numerous functions within the hostfxr dynamic library, it is unknown which are essential for the .NET runtime to run on other operating systems (such as Linux). Therefore, it is necessary to search within the dynamic library for the necessary functions for the .NET runtime to run on the primary operating system (such as Linux).

[0087] The steps of searching for necessary functions in this embodiment include:

[0088] 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 in the figure, 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 symbol table in the so file is obtained by parsing the so file, thereby obtaining the name and position of the function in the symbol table, as shown in the figure. Figure 3 、 Figure 4 shown.

[0089] S12 groups the functions in the symbol table according to a preset grouping rule to obtain several grouped symbol sub-tables, as shown in Table 1:

[0090] Table 1 Grouping symbol subtable

[0091]

[0092] The preset grouping rules described in this embodiment are:

[0093] 1. Group functions that have the same prefix, come from the same dynamic library file, and belong to the same initialization function module.

[0094] Functions from the same so file and the same initialization module often have close functional dependencies, data sharing, initialization dependencies, resource management, security, and performance optimization. Grouping these functions together can better organize code, manage resources, improve performance, and ensure system stability and security. Specifically, these include:

[0095] 1. Module cohesion. Functional relevance: These functions typically serve the same functional module or subsystem, collectively implementing a specific set of functionality or business logic. For example, the functions in a database access module might all be used for database operations (such as insert, delete, and query). Data sharing: These functions might operate on the same internal data structures or state, and therefore need to share the same data context. For example, the functions in a graphics rendering module might all need to access the same geometry or texture data.

[0096] 2. Dependencies. Code dependencies: Functions in the same functional module often call or depend on each other. For example, a function in a file processing module might call another function to read and write files. Resource dependencies: Functions may depend on the same resources or external services. For example, functions in a network communication module might all need to access the same network socket or configuration.

[0097] 3. Initialization and lifecycle management. Initialization order: Functions within the same module may need to be initialized in a specific order at program startup. Grouping ensures that these functions are initialized in the correct order, avoiding errors caused by uninitialized functions. Resource release: These functions may need to release resources uniformly at program termination. Grouping ensures that all related resources are properly released at the end of the module's lifecycle.

[0098] 4. Consistency and security. Security checks: Functions within the same functional module may require the same security checks or permission verification. Grouping allows for unified security settings and checks 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 errors.

[0099] 5. Performance Optimization. Cache Utilization: Functions within the same functional module may operate on the same data structures. Grouping them allows for better utilization of the CPU cache, reducing cache misses and thus improving operational efficiency. Resource Management: Functions may need to manage the same types of resources (such as memory and file handles). Grouping allows for more efficient management of these resources, reducing resource contention and conflicts.

[0100] It can be seen from this that functions from the same so file and the same initialization function module are more conducive to finding the necessary functions for the .NET runtime to run under Linux.

[0101] 2. Mark the function groups into necessary function groups and functional function groups (optional function groups) according to function attributes.

[0102] Functions in the hostfxr dynamic library are broadly categorized into two groups: essential functions and functional functions. Essential functions are those that the .NET runtime must call during operation; in other words, the .NET runtime cannot function without them. Depending on the operating environment, for example, the functions called vary depending on the operating system. Functional functions, on the other hand, are those called by .NET to implement a specific function and are not essential for operation. It is understandable that categorizing function attributes facilitates quick identification of essential functions for the .NET runtime running under Linux. To distinguish between essential and functional functions, one can generally use the prefix of the function name. For example, a function prefixed with hostfxr is most likely an essential function, while a function prefixed with coreclr is most likely a functional function.

[0103] 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.

[0104] The preset calling rules described in this embodiment include: 1. Prioritizing functions in the necessary function group for verification. It's easy to understand that the functions in the necessary function group are essential for the .NET runtime to run under the first operating system (e.g., Linux), so calls to functions in the necessary function group are limited. 2. Prioritizing multiple group symbol sub-tables based on the number of times each group symbol sub-table has been successfully loaded in different environments. The higher the number of successful loads, the higher the priority. These sub-tables are loaded sequentially in descending order until they are successfully loaded. Generally speaking, a higher number of successful loads indicates that the sub-table is capable of creating a runtime environment for DotNet Core in various operating environments, i.e., its compatibility is higher. Preferably, the number of successful loads for each group symbol sub-table in different environments is based on historical data statistics or pre-tested. When each necessary function in the group symbol sub-table is successfully loaded, a value (e.g., true) is returned. Accordingly, receiving this return value indicates that the group symbol sub-table has passed verification, meaning that the sub-table has been successfully loaded.

[0105] This embodiment groups the symbol table and calls the test run according to pre-set priorities. This significantly reduces the cost and probability of trial and error compared to direct random calls or blind one-by-one test runs. Consequently, it is possible to more quickly find multiple necessary functions for building a .NET runtime under a first operating system (e.g., a Linux operating system). Through this approach, this embodiment selects hostfxr_initialize_for_runtime_config and hostfxr_get_runtime_delegate from the hostfxr dynamic library as essential functions for running the .NET runtime under Linux. 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 based on the provided runtime configuration file. The hostfxr_get_runtime_delegate function is used to obtain the delegate for a specific .NET runtime function. This function can be used to obtain access to various functions within the .NET runtime, such as loading assemblies and obtaining type information.

[0106] Exemplarily, the above two functions are the minimum parameter configurations for the .NET runtime running under the Linux system.

[0107] S2 encapsulates the C++ interface into a C# interface under Linux; when encapsulating the interface, it converts the data type of CAD under Linux into the data type of CAD under .NET.

[0108] Through step S1, the .NET runtime is successfully run under a first operating system (e.g., Linux), allowing the CAD platform under the first operating system to call the .NET application plug-in. However, secondary development requires not only calling the .NET plug-in but also using a programming language. A popular programming language for CAD platforms is C#, an object-oriented programming language developed by Microsoft. Compared to C++, it is less complex and easier to learn. However, C# is a Windows programming language and is not directly supported under first operating systems such as Linux. C++, on the other hand, is a cross-platform language well supported on first operating systems such as Linux. Therefore, in this step, the C++ interface is encapsulated as a C# interface under the first operating system such as Linux, allowing users to call the .NET application plug-in for CAD under the first operating system such as Linux through C#. Furthermore, the representation of data types in C++ and C# differs. Since the present invention targets secondary development of CAD, some special data types of the CAD platform are also involved, as shown in Table 2.

[0109] Table 2 Examples of data type rules in C#, C++, and CAD environments

[0110]

[0111] As shown in the table above, even for the same data type, the rules differ across the three different environments. For example, a data type may be sbyte in C#, but char in C++ and CAD. Another example is int in C# and C++, but int32 in CAD. The above table is merely an example; in real applications, data types are more complex and can be combined.

[0112] The main steps for encapsulating a C++ interface into a C# interface on a Linux-based operating system include: preparing a C++ dynamic library, exporting C++ functions using extern "C", declaring function prototypes in C# using the DllImport attribute, performing data type conversion, encapsulating complex data types, handling callback functions, and finally testing and debugging. These steps enable seamless integration between C++ and C#. The specific steps include:

[0113] 1. Prepare a 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.

[0114] 2. Use extern "C" to export C++ functions. To make C++ functions callable from C#, you need to use the extern "C" modifier to export these functions to avoid C++ name mangling issues.

[0115] / / C++ code exampleextern "C" {

[0116] __declspec(dllexport) int Add(int a, int b);

[0117] __declspec(dllexport) void PrintHello();}

[0118] 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.

[0119] using System.Runtime.InteropServices;

[0120] public class NativeMethods {

[0121] [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)]

[0122] public static extern int Add(int a, int b);

[0123] [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)]

[0124] public static extern void PrintHello();}

[0125] 4. Data type conversion.

[0126] In C#, you need to perform appropriate conversions based on the data type of the C++ interface. Common data type conversions include:

[0127] Basic data types: such as int, float, double, bool, etc. can be mapped directly.

[0128] Pointer type: Use IntPtr or HandleRef to handle.

[0129] String type: Use Marshal.PtrToStringAnsi or Marshal.PtrToStringUni to convert char* or wchar_t*.

[0130] Complex data types, such as structures and classes, require the use of the StructLayout and FieldOffset attributes in C# to define their memory layout.

[0131] 5. Encapsulation of complex data types.

[0132] If the C++ interface involves complex data types (such as structures or classes), corresponding encapsulation and conversion are required in C#.

[0133] Example: Encapsulating a Struct

[0134] / / C++ code example struct Point {

[0135] int x;

[0136] int y;};

[0137] extern "C" {

[0138] __declspec(dllexport) void SetPoint(Point p);

[0139] __declspec(dllexport) Point GetPoint();}

[0140] / / C# code example using System.Runtime.InteropServices;

[0141] [StructLayout(LayoutKind.Sequential)]public struct Point {

[0142] public int x;

[0143] public int y;}

[0144] public class NativeMethods {

[0145] [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)]

[0146] public static extern void SetPoint(Point p);

[0147] [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)]

[0148] public static extern Point GetPoint();}

[0149] 6. Process the callback function.

[0150] If the C++ interface requires a callback function, it can be encapsulated in C# through a delegate.

[0151] Example: Callback Function

[0152] / / C++ code example typedef void (*CallbackFunction)(int);

[0153] extern "C" {

[0154] __declspec(dllexport) void RegisterCallback(CallbackFunctioncallback);}

[0155] / / C# code example using System; using System.Runtime.InteropServices;

[0156] public class NativeMethods {

[0157] public delegate void CallbackFunction(int value);

[0158] [DllImport("libNativeLibrary.so", CallingConvention =CallingConvention.Cdecl)]

[0159] public static extern void RegisterCallback(CallbackFunctioncallback);}

[0160] 7. Testing and debugging.

[0161] After the 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.

[0162] When encapsulating a C++ interface into a C# interface, data type conversion from C++ to C# is involved. The above conversion process can be understood as a general data type conversion process.

[0163] Since the purpose of the present invention is to perform secondary development of CAD using a .NET plug-in and C# in a first operating system such as Linux or a first operating environment, in addition to converting data types from C++ to C#, it is more important to convert the CAD data type in the first operating system such as Linux to the CAD data type in .NET (for example, GCAD data type). The specific steps include:

[0164] S21 obtains the data type rules of CAD under the first operating system and the data type rules of CAD under .NET.

[0165] like Figure 5 As shown, the data of the CAD platform in the C++ operating environment:

[0166] "bool operator == (const GcGeMatrix3d&mat) const;

[0167] bool operator != (const GcGeMatrix3d&mat) const;”

[0168] like Figure 6 As shown, the same data in the CAD platform under the C# operating environment is:

[0169] “public bool IsEqualTo(Matrix3d mat);

[0170] public bool IsEqualTo(Matrix3d mat, Tolerance tolerance);".

[0171] Due to the diversity of data types, many have their own unique data type rules. Therefore, you must obtain the data type rules for the corresponding data type in both language environments before you can convert between the two. Furthermore, data type rules are not universal and vary from one data type to another.

[0172] 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.

[0173] Conversion between data types requires corresponding conversion syntax rules. For example, converting data from a CAD platform in a C++ runtime environment to data from a CAD platform in a C# runtime environment requires conversion syntax rules.

[0174] Continuing with the previous example, Figure 7 is an example of a transformation grammar rule.

[0175] If it is expressed as "GcGeMatrix3d::operator *" in the C++ runtime environment (where "GcGeMatrix3d:" is the class name and ":operator *" is a specific presentation format), it will be converted to "times" in the C# runtime environment.

[0176] For example, if it is expressed as "GcGeMatrix3d::operator ==" in the C++ runtime environment, it will be converted to "equal" in the C# runtime environment.

[0177] S23 uses the conversion grammar rules to batch convert the CAD data types in the first operating system or the first operating environment into CAD data types in .NET.

[0178] Due to the large number of data types, manual conversion would be extremely labor-intensive. Therefore, the present invention automatically batch-converts CAD data types in a first operating system, such as Linux, into CAD data types in .NET by writing conversion grammar rules into a script. A script is a code or instruction sequence used to automate tasks. Scripts are typically used to execute a series of predefined operations without manual intervention.

[0179] 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, thereby performing secondary development of the CAD simply and quickly.

[0180] like Figure 8 As shown, the C++ interface describing the data type is encapsulated to obtain the C# interface Curve2d.cs.

[0181] Example 2: The present invention also provides a system for performing CAD secondary development based on a .NET runtime, comprising:

[0182] A runtime environment building module is used to dynamically load a 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 runtime environment, thereby 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;

[0183] 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 CAD data type in the first operating system or the first operating environment is converted into the CAD data type in .NET.

[0184] Preferably, the above-mentioned operating environment construction module is specifically used to: parse 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; group the functions in the symbol table according to preset grouping rules to obtain several grouped symbol sub-tables; call the corresponding function according to the preset calling rules and based on the address information in the grouped symbol sub-table for verification; and use the successfully verified function as a necessary function.

[0185] 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 groups into necessary function groups and functional function groups according to function attributes.

[0186] 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 group symbol sub-table is successfully loaded in different environments, multiple group 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.

[0187] Example 3: See Figure 9 The present invention provides a method for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which comprises the steps of:

[0188] S101, in a first operating environment, dynamically loading Dotnet core to match 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).

[0189] 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.

[0190] 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 a preset filtering rule, 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).

[0191] S202: Group the symbol table according to a preset grouping rule to obtain multiple grouped symbol sub-tables. In some embodiments, the preset grouping rule includes: screening multiple necessary functions based on attribute information, and then grouping the necessary functions from the same .so file and the same initialization function module into one group, as shown in Table 1 above. The attribute information includes the definition of each function (including: name, parameters, etc.).

[0192] S203, according to the preset calling rules, and according to the address information in the grouping symbol subtable, calling the corresponding calling object for verification. If the verification passes, the calling object (i.e., multiple necessary functions) for building the second operating environment for Dotnet core is obtained.

[0193] In some embodiments, the preset calling rule includes: prioritizing multiple grouping symbol sub-tables based on the number of times each grouping symbol sub-table is successfully loaded under different operating environments, wherein a higher number of successful loadings has a higher priority, and calling the trial run in descending order of priority. Generally speaking, the more times a sub-table is successfully loaded, the more capable it is of creating an operating environment for Dotnet core in various operating environments, that is, its compatibility is higher.

[0194] Preferably, the number of times each grouping symbol sub-table is successfully loaded under different environments is obtained based on historical data statistics or multiple tests performed in advance. Specifically, the testing process is in accordance with the above steps S201 to S203.

[0195] In this embodiment, by grouping the symbol tables and calling the trial run according to a pre-set priority, the trial and error cost and probability are greatly reduced compared to the direct random call or blind one-by-one call trial run method. Therefore, multiple necessary functions for building a second operating environment for Dotnet core can be found more quickly.

[0196] In some embodiments, the above-mentioned 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.

[0197] As shown in Table 2 above, even for the same data type, the rules differ across the three different environments. For example, a data type may be sbyte in Windows, but char in Linux and GCAD. Another example is int in Windows and Linux, but int32 in GCAD. The above table is merely an example; in actual applications, data types are more complex and can be combined. In some embodiments, the first execution environment is the C++ execution environment, the second execution environment is the C# execution environment, and the third execution environment is the GCAD platform environment.

[0198] S302: Construct 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. In other words, the data type rules in the three environments must be integrated.

[0199] 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.

[0200] 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 format in the C++ environment), it is converted to the first data type. Figure 7 If it is expressed as "GcGeMatrix3d::operator *" in the C++ runtime environment (where "GcGeMatrix3d:" is the class name and ":operator *" is a specific presentation format), it will be converted to "times" in the C# runtime environment.

[0201] For example, if it is expressed as "GcGeMatrix3d::operator ==" in the C++ runtime environment, it will be converted to "equal" in the C# runtime environment.

[0202] For example, see Figure 5 , before conversion: Data of GCAD platform in C++ operating environment:

[0203] "bool operator == (const GcGeMatrix3d&mat) const;

[0204] bool operator != (const GcGeMatrix3d&mat) const;”

[0205] After conversion, we can get the data of GCAD platform in C# running environment, see Figure 8 :

[0206] “public bool IsEqualTo(Matrix3d mat);

[0207] public bool IsEqualTo(Matrix3d mat, Tolerance tolerance);".

[0208] S303: Based on the conversion grammar rules, the C++ interfaces are encapsulated in batches to be converted into C# interfaces under 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 using its corresponding conversion syntax rules to obtain the C# interface on the right. For example, dbcurve.h, which describes a data type, is converted (or encapsulated) using its corresponding conversion syntax rule dbcurve.i to obtain Curve2d.cs.

[0209] Example 4: See Figure 12 The present invention also provides a system for implementing dotnet secondary development of .NET7 runtime based on Linux GCAD platform, which includes:

[0210] 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;

[0211] 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.

[0212] Example 5: See Figure 10 The present invention also provides a method for constructing a running environment for a C# interface in dotnet secondary development based on a Linux GCAD platform for .NET7 runtime, which comprises the steps of:

[0213] 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.

[0214] 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 a preset filtering rule, and then obtaining the symbol table of the target so file.

[0215] In some embodiments, this loads the hostfxr dynamic library provided by Microsoft (the hostfxr library exposes functions for the managed .NET runtime).

[0216] S202 : Grouping the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables.

[0217] 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 one group.

[0218] 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.

[0219] In some embodiments, the preset call rule includes: prioritizing multiple grouped symbol sub-tables based on the number of times each grouped symbol sub-table has been successfully loaded under different circumstances, wherein a higher number of successful loads gives a higher priority, and trial runs are called sequentially in descending order of priority until a successful load is found (i.e., verification is passed). Specifically, each grouped symbol sub-table corresponds to multiple required functions, and when each required function in the grouped symbol sub-table is successfully loaded, a value (e.g., true) is returned. Accordingly, receiving this return value indicates that the grouped symbol sub-table has passed verification, i.e., the grouped symbol sub-table has been successfully loaded.

[0220] Preferably, the number of times each grouping symbol sub-table is successfully loaded under different environments is obtained based on historical data statistics or multiple tests performed in advance.

[0221] Example 6: The present invention also provides a device for building a running environment for a C# interface in dotnet secondary development based on a Linux GCAD platform for implementing a .NET7 runtime, comprising:

[0222] The first loading module is used to 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;

[0223] a grouping module, configured to group the symbol table according to a preset grouping rule to obtain a plurality of grouped symbol sub-tables;

[0224] 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.

[0225] Example 7: See Figure 11 The present invention also provides an interface encapsulation method for implementing dotnet secondary development in .NET7 runtime based on Linux GCAD platform, which comprises the steps of:

[0226] 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;

[0227] S302, constructing a conversion grammar rule between the second data type rule in the second operating environment and the third data type rule in the third operating environment;

[0228] 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.

[0229] Example 8: The present invention also provides an interface encapsulation device for implementing dotnet secondary development in .NET7 runtime based on the Linux GCAD platform, which includes:

[0230] A data acquisition module, configured 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;

[0231] A grammar construction module, configured to construct a conversion grammar rule between the second data type rule in the second operating environment and the third data type rule in the third operating environment;

[0232] The encapsulation module is used to encapsulate 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.

[0233] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0234] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially 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, magnetic disk, optical disk), including a number of instructions for enabling a computer terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0235] 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 methods. The above-mentioned specific implementation methods are merely illustrative and not 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 protected by 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 loading a hostfxr dynamic library and calling necessary functions in the hostfxr dynamic library for the .NET runtime to run in the first operating system or the first operating environment, thereby building a second operating environment for the .NET runtime in the first operating system or the first operating environment, thereby enabling the .NET program to run in the first operating system or the first operating environment; the first operating system is an operating system other than the Windows operating system; 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 a plurality of 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; The function that verifies success is considered 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 that have the same prefix, come from the same dynamic library file, and belong 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 group symbol sub-table is successfully loaded in different environments, multiple group symbol sub-tables are prioritized, wherein the higher the number of successful loadings, the higher the priority, and they are loaded in descending order 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 CAD data type in the first operating system or the first operating environment into the CAD data type in .NET includes: Obtaining a data type rule for CAD in the first operating system or the first operating environment and a data type rule for 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 to the data type of CAD in .NET according to the acquired data type rule; The conversion grammar rules are used to batch convert the CAD data types in the first operating system or the first operating environment into the CAD data types in .NET.

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 a script.

7. A cross-operating system .NET runtime calling method, characterized in that: Including 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 grouped symbol 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 a group; marking the function group into a necessary function group and a functional function group according to function attributes; wherein the necessary function is the most basic function required for Dotnet core to build an operating environment, and by calling the necessary function, the CAD platform under the first operating system or the first operating environment can call the .NET application plug-in; the first operating system is an operating system other than the Windows operating system; According to the preset calling rules, and based on 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: prioritizing multiple grouped symbol subtables based on the number of times each grouped symbol subtable is successfully loaded in different environments, wherein the higher the number of successful loadings, the higher the priority, and loading is performed in descending order until successful loading.

9. A system for CAD secondary development based on .NET runtime, characterized by include: A runtime environment building module, configured to dynamically load a hostfxr dynamic library in a first operating system or a first runtime environment, and call, in the hostfxr dynamic library, necessary functions for the .NET runtime to run in the first operating system or the first runtime environment, thereby building a second runtime environment for the .NET runtime in the first operating system or the first runtime environment, thereby enabling the .NET program to run in the first operating system or the first runtime environment; wherein the necessary functions are functions that must be called by the .NET runtime during operation, and by calling the necessary functions, the CAD platform in the first operating system or the first runtime environment can call the .NET application plug-in; and the first operating system is an operating system other than the Windows operating system; 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 CAD data type in the first operating system or the first operating environment is converted into the CAD data type in .NET.

10. The system for CAD secondary development based on .NET runtime according to claim 9, characterized in that The operating environment construction 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 grouped symbol sub-tables; then, according to the preset calling rules, and based on the address information in the grouped 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

  • Automatic and quick processing method for information of I / O (Input / Output) points on the basis of AutoCAD (Autodesk Computer Aided Design)

    CN106951577A

  • System and method for managed tuxedo wrapper for .net applications

    US20080271007A1