Node calls C # file

Source: Internet
Author: User

Recently in the software to prepare the function, the background using node for development. problem

In the process of development, you need to obtain version information and name of the software, but the method of node getting file information Fs.stats method is not able to meet the requirements. We need to get to the contents of the following diagram

The version of the product and the name of the product. But C # is available with the appropriate API. Solve

Find the corresponding development wrote a DLL, specifically to get the information of the file. The code is as follows:

The simple thing about the code is to return an object with the name of the file and the version number. Here's a new feature of. NET, Task,async, as to why encapsulation into Func edge is what

Edge is a bridging technology that implements NODEJS and. NET interoperability in the process, and can use. NET code and libraries in Nodejs, or you can use Nodejs code in. NET programs.


Edge operation requires. netframework4.5, which uses the. NET task, async, await mechanism to match the Nodejs event model. Essentially, it connects the V8 engine and the. NET/MONOCLR runtime while supporting Windows, MacOS, and Linux. It also supports various scripting languages running on the. NET CLR. By bridging technology in this process, the various class libraries and other technologies on either side can be nodejs, such as using the. NET Image processing library GDI +, directly manipulating the SQL Server database with ado.net, or even directly calling WinForm code to implement the desktop UI program, and so on.

Introduction to the concept of a bunch of actually we still see how to use it.

var Objdll = Edge.func ({
    assemblyfile: './libs/fileinfo.dll ',//c# file path
    typeName: ' Fileinfo.fileinfotask ',// namespace + class name
    methodname: ' GetFileInfo '//Method name
};
var fileInfo = Objdll (Path.resolve ('./public/attachments/' + req.query.fileName), true);

The above can solve our problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.