Giter VIP home page Giter VIP logo

clrtest's Introduction

CLRTest

Demo about C++ using C# dll

项目Trianlge来自于Trianlge.NET

Demo 1

CSharpDLL生成了一个简单的C#类库

CLRTest是一个使用了CLR开关的CLI/C++程序

  1. 使用#using指令包含C#的dll文件
  2. 用^标识托管对象
  3. 用gcnew创建托管对象
  4. 托管对象的使用类似于指针

Demo 2

给出了一个在非托管C++中调用C#库的解决方法

简单思路:使用CLI/C++封装对C#库的操作,生成一个中间DLL,然后在非托管C++中调用中间DLL。

一些碰到的问题

  1. C++在导出函数时,会对函数名进行修饰,其后果就是在调用时很难直接确定函数入口。

    解决方法:

    • 包含导出函数的头文件
    • 添加静态链接库
    #pragma comment(lib, "../x64/Debug/usingTriangle.lib")
    #include"../usingTriangle/usingTriangle.h"
    

    在加载DLL之后,即可调用导出的C++函数。

clrtest's People

Contributors

yiluomyt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.