关于调用托管C++函数

问题描述

本人现在要用托管C++做一个返回为List的函数,但是怎么调试都不成功代码如下h头文件#pragmaonceusingnamespaceSystem;usingnamespaceSystem::Data;usingnamespaceSystem::Data::SqlClient;usingnamespaceSystem::Collections::Generic;classdatabas_xg{public:intsum(inta,intb);//测试用的求和函数//List<>^data_get(String^sql);List<int>^GetList();};cpp文件#include"StdAfx.h"#include"databas_xg.h"//usingnamespaceSystem::Collections::Generic;intdatabas_xg::sum(inta,intb){inthaha=a+b;returnhaha;}List<int>^GetList(){List<int>^a=gcnewList<int>();for(inti=0;i<10;i++){a->Add(i+1);}returna;}控件中调用该类中的函数private:System::Voidbutton5_Click(System::Object^sender,System::EventArgs^e){String^sql="Select*fromchild_account";databas_xg*C_a=newdatabas_xg();List<int>^aa=gcnewList<int>();//aa=C_a->GetList();}将上边改为databas_xgC_a;List<int>aa;aa=C_a->GetList();反正怎么弄都不对,老是报错,请各位大神看看应该怎么调用谢谢!我是小菜鸟,没分送。。。

解决方案

解决方案二:
List<int>aa;aa=C_a->GetList();==>List<int>^aa;aa=C_a.GetList();
解决方案三:
引用1楼Saleayas的回复:

List<int>aa;aa=C_a->GetList();==>List<int>^aa;aa=C_a.GetList();

不对诶,如果用C_a.GetList();如果用.根本就弹不出这个方法了。。。用->应该是对的
解决方案四:
引用1楼Saleayas的回复:

List<int>aa;aa=C_a->GetList();==>List<int>^aa;aa=C_a.GetList();

将声明部分改为databas_xgC_a;用的就是aa=C_a.GetList();了但是均报错errorLNK2028:unresolvedtoken(0A000009)"public:classSystem::Collections::Generic::List<int>^__clrcalldatabas_xg::GetList(void)"(?GetList@databas_xg@@$$FQAMP$AAV?$List@H@Generic@Collections@System@@XZ)referencedinfunction"private:void__clrcalldenglu_test::F_zhuzhanghu::button5_Click(classSystem::Object^,classSystem::EventArgs^)"(?button5_Click@F_zhuzhanghu@denglu_test@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)不知道怎么办
解决方案五:
已自行解决,请关闭问题。

时间: 2024-09-20 17:50:38

关于调用托管C++函数的相关文章

cpp-请问非托管C++中是否可以调用C#的函数

问题描述 请问非托管C++中是否可以调用C#的函数 请问一个项目里面可不可以创建CS文件和CPP文件,并在CPP文件中调用CS文件中的类方法. 解决方案 当然可以,将你的C#程序包装成com对象,用regasm注册. 在你的C++中CoCreateInstance像调用COM对象那样就可以用 http://www.360doc.com/content/12/1218/08/9200790_254706077.shtmlhttp://www.codeproject.com/Articles/126

JavaScript EE,第2部分:用Ajax调用远程JavaScript函数

在本系列的第1部分中,您学习了如何在Asynchronous JavaScript and XML(Ajax)和Java Platform, Enterprise Edition(Java EE)应用程序中使用javax.script API.本文将展示如何为同时在服务器和客户机上使用JavaScript的Web 应用程序实现远程过程调用(Remote Procedure Call,RPC)机制.您还将学习一些有趣的技巧,例如用JavaScript实现Java接口.构建XMLHttpReques

C#调用C++回调函数的问题

C++的回调函数中有一个参数是,是返回一个字符串,原则如下: typedef void (*TDataEvent)(char *AData ,int ALen); 其中char *AData是从DLL中返回一个字符串,串的内存已经在DLL中分配了 下面中我在C#中定义的委托 public delegate void TDataEvent(Byte[] AData, int ALen); 下面是回调函数的设置代码: Event=new clReceivelDllPoxy.TDataEvent(ge

asp.net C#调用托管DLL和非托管DLL文件的区别

asp教程.net c#调用托管dll和非托管dll文件的区别 托管dll文件,可以在dotnet环境通过 "添加引用" 的方式,直接把托管dll文件添加到项目中.然后通过 using  dll命名空间,来调用相应的dll对象 .     非托管dll文件,在dotnet环境应用时,通过 dllimport 调用.    c# 调用非托管dll文件.dll文件是用c语言编写的. 如下: 1:结构定义   rditag_t     rditag_t结构定义了测点的结构   typedef

struts-urlrewrite 如何配置向特定action跳转并调用指定的函数

问题描述 urlrewrite 如何配置向特定action跳转并调用指定的函数 我设定一个rule /edit/(2[0-9]{3})$/essayAction.action?method=editEssay&id=$1 希望将http://127.0.0.1:8080/iBlog/essay/2000的请求 映射到:http://127.0.0.1:8080/iBlog//essayAction.action?method=editEssay&id=2000 结果错误提示我,没有excu

用Visual C#调用Windows API函数(转)

visual|window|函数 用Visual C#调用Windows API函数 北京机械工业学院研00级(100085)冉林仓       Api函数是构筑Windws应用程序的基石,每一种Windows应用程序开发工具,它提供的底层函数都间接或直接地调用了Windows API函数,同时为了实现功能扩展,一般也都提供了调用WindowsAPI函数的接口, 也就是说具备调用动态连接库的能力.Visual C#和其它开发工具一样也能够调用动态链接库的API函数..NET框架本身提供了这样一种

c#调用Win32 Api函数

在c#中可以通过互操作性服务using System.Runtime.InteropServices来调用window api函数.并且通过属性来指定api函数的位置,以及调用方式,比如,我们要调用User32.dll里的函数MessageBox(HWnd hwnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT type) 首先引入名字空间 using System.Runtime.InteropServices; 其次定义一个静态方法,并且指定调用的方式.其中用关

为什么在调用Huffmancoding 这个函数后会导致head发生变化了?

问题描述 为什么在调用Huffmancoding 这个函数后会导致head发生变化了? #include #include #include int count=0;//用来计算叶子结点 int NUM=0;//用来计算短文字母总数 int min[2]; typedef struct Essays { char ch; int num; struct Essays *next; }Essay; typedef struct Huff_Trees { unsigned int weight; u

对象-oc 类的继承的实质,以及是怎样调用方法 和函数的

问题描述 oc 类的继承的实质,以及是怎样调用方法 和函数的 父类里声明的属性,会生成默认生成一个私有的成员变量.即不能被子类访问,那么子类通过继承得到了父类的属性,只能通过setter 和 getter 方法区访问父类的私有变量,那么这个私有变量不属于子类,那么在实例化这个子类的时候就没有这个私有变量,那么通过继承过来的setter 和getter方法访问的是什么,私有变量根本就没有生成啊! 同理在使用{}声明的私有变量同样可以在提供外部接口让外部访问,但是当子类继承后也可以通过生成实例对象,