当前位置: 首页 > news >正文

做销售用什么网站好微博推广费用一般多少

做销售用什么网站好,微博推广费用一般多少,你做的网站可视区域多少钱,wordpress安装一下C调用C#方法 写在前面效果思路步骤可能的问题 写在后面 写在前面 工作需要用C调用C#写到代码,看来网上写的方法,自己也踩了一些坑,这里总结一下,我只试了CLR的方法。 主要参考了下面几篇博客 C调用C#库简单例程(Lucky…

C++调用C#方法

  • 写在前面
    • 效果
    • 思路
    • 步骤
    • 可能的问题
  • 写在后面

写在前面

工作需要用C++调用C#写到代码,看来网上写的方法,自己也踩了一些坑,这里总结一下,我只试了CLR的方法。
主要参考了下面几篇博客
C++调用C#库简单例程(Lucky的outlook应该使用了这个技术
C++ 调用C#工程的 dll , 互相调用方法
C++调用C#的库

效果

这里用C++调用C#类的加法函数实现2+3,然后调用C#的Console.WriteLine打印
在这里插入图片描述

思路

C#生成DLL文件,C++调用C#的DLL

步骤

1、创建C# .NET Framework类库
注意是.NET Framework类库,不要创建错了
在这里插入图片描述
我命名为CSAdd
在这里插入图片描述
这里我们在CSAdd命名空间下写了一个Class1类。类中写两个函数,一个Add函数实现加法,一个Print函数调用Console.WriteLine
注意这个类在CSAdd命名空间下,所以后面的C++调用要先引用这个命名空间才能创建Class1类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace CSAdd
{public class Class1{public int Add(int a,int b){return a + b;}public void Print(String str){Console.WriteLine(str);}}
}

2、创建CPP项目
创建控制台应用
在这里插入图片描述
我命名为CPPInvokeCSAdd
在这里插入图片描述
在高级中开启clr
在这里插入图片描述
C/C++ —>语言---->符合模式设为否
在这里插入图片描述
我们写个main函数直接运行
在这里插入图片描述
可以看到exe文件确实生成在了\x64\Debug目录下
在这里插入图片描述

3、修改C#DLL的生成路径

在C#项目中把输出路径改为c++项目exe的输出路径上,也就是上面的\x64\Debug路径
在这里插入图片描述生成DLL,可以看到我们的CSAdd.dll生成在了这个目录下。
注意C#的DLL一定要和C++生成的exe在同一个目录下
在这里插入图片描述

4、编写C++程序,调用C#的DLL
关键点:
(1)使用#using 引用C#的dll,因为C#的dll放在C++项目下所以用../x64/Debug/CSAdd.dll代替完整路径F:\C++\CPPInvokeCSAdd\x64\Debug,写完整路径也可以。
(2)使用using namespace引入dll中的命名空间CSAdd,这样才能调用Class1
同时我们还迎入了C#的System命名空间,这是因为我们要在C++中创建C#的String对象(在System命名空间下)作为Print函数的参数(因为Print函数是C#实现了,所以不支持C++的std::string)。
(3)使用gcnew创建C#对象
(4)用 类名^ 表示C#的对象,所以这里用Class1^ dll,而不是Class1 dll。在C++/CLI中这个^类似于C++中的指针,但是因为C#有虚拟机,所以Class1^ dll实际是虚拟机在管内存的分配与回收,而不想C++的指针那样new的东西需要自己回收。
(5)因为dll->Print是调用C#中的方法,所以Print参数类型String也必须C#类型,所以创建了String^ resultStr
(6)为什么resultInt变量能调用ToString()方法?因为resultInt的类型是C#的int不是C++的int(我有点疑惑,具体得看看CLI的语法),所以直接dll->Print(resultInt.ToString())也是可以的。

//使用#using引用C# DLL,而不是#include;
#using "../x64/Debug/CSAdd.dll" 
// 引入CSAdd、System的命名空间
using namespace CSAdd;
using namespace System;int main()
{Class1^ dll = gcnew Class1();//使用gcnew创建dll中的对象指针int resultInt = dll->Add(2, 3);//调用dll对象中的方法String^ resultStr = gcnew String(resultInt.ToString());dll->Print(resultStr);return 0;
}

运行
在这里插入图片描述
5、如果之后要修改C#的代码
因为前面设置了C#项目中DLL是直接生成在C++项目的目录下的,所以修改完C#代码后直接在C#项目中点击生成就行了,不用该C++代码。
如果C++中#using "../x64/Debug/CSAdd.dll"这行编译器提示出错,把这行删了重写一次就好了。

可能的问题

报错:未能加载文件
在这里插入图片描述
可能原因:C++生成的exe和C#生成的dll不在同一个目录下,一定要在同一个目录下
在这里插入图片描述
解决办法:
C++项目的常规->输出目录、链接器->输出文件、c#的dll生成目录都是同一目录
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

写在后面

初入职场,上班好累啊,呜呜呜。
在这里插入图片描述


文章转载自:
http://huhehot.xsfg.cn
http://vigorousness.xsfg.cn
http://seaborne.xsfg.cn
http://hobart.xsfg.cn
http://necromimesis.xsfg.cn
http://sceptre.xsfg.cn
http://rarotonga.xsfg.cn
http://rand.xsfg.cn
http://productive.xsfg.cn
http://indelibly.xsfg.cn
http://tort.xsfg.cn
http://inaccessible.xsfg.cn
http://teasingly.xsfg.cn
http://briber.xsfg.cn
http://isokite.xsfg.cn
http://dottle.xsfg.cn
http://stagnant.xsfg.cn
http://sallee.xsfg.cn
http://protectingly.xsfg.cn
http://steve.xsfg.cn
http://patristic.xsfg.cn
http://street.xsfg.cn
http://imperiality.xsfg.cn
http://carriage.xsfg.cn
http://lak.xsfg.cn
http://gyre.xsfg.cn
http://unchurched.xsfg.cn
http://snip.xsfg.cn
http://wavey.xsfg.cn
http://epizoic.xsfg.cn
http://esurient.xsfg.cn
http://laten.xsfg.cn
http://algonquin.xsfg.cn
http://telamon.xsfg.cn
http://coordinal.xsfg.cn
http://discount.xsfg.cn
http://doggerelize.xsfg.cn
http://dizzily.xsfg.cn
http://battlements.xsfg.cn
http://uninstructed.xsfg.cn
http://neutralistic.xsfg.cn
http://autographic.xsfg.cn
http://squareness.xsfg.cn
http://pyogenous.xsfg.cn
http://rehearse.xsfg.cn
http://bewilderingly.xsfg.cn
http://exocentric.xsfg.cn
http://symbolise.xsfg.cn
http://collect.xsfg.cn
http://anergy.xsfg.cn
http://uncontrived.xsfg.cn
http://regulative.xsfg.cn
http://epoxide.xsfg.cn
http://lomotil.xsfg.cn
http://betoken.xsfg.cn
http://highflyer.xsfg.cn
http://peep.xsfg.cn
http://invidious.xsfg.cn
http://scandinavian.xsfg.cn
http://lysogeny.xsfg.cn
http://hyperostotic.xsfg.cn
http://ichthyosaurus.xsfg.cn
http://monandrous.xsfg.cn
http://seducement.xsfg.cn
http://histogen.xsfg.cn
http://arioso.xsfg.cn
http://forepast.xsfg.cn
http://catomountain.xsfg.cn
http://inductee.xsfg.cn
http://overcall.xsfg.cn
http://vicissitude.xsfg.cn
http://hemochromogen.xsfg.cn
http://tantalization.xsfg.cn
http://isadora.xsfg.cn
http://fetlock.xsfg.cn
http://ain.xsfg.cn
http://valorise.xsfg.cn
http://talebearer.xsfg.cn
http://marijuana.xsfg.cn
http://dustbrand.xsfg.cn
http://lassen.xsfg.cn
http://differentiator.xsfg.cn
http://marquesa.xsfg.cn
http://divalent.xsfg.cn
http://bedstone.xsfg.cn
http://pious.xsfg.cn
http://uprise.xsfg.cn
http://musth.xsfg.cn
http://workaholic.xsfg.cn
http://analysable.xsfg.cn
http://pictorialize.xsfg.cn
http://chanceless.xsfg.cn
http://immutability.xsfg.cn
http://pawnbroker.xsfg.cn
http://rustling.xsfg.cn
http://benedick.xsfg.cn
http://viga.xsfg.cn
http://applicatively.xsfg.cn
http://smogbound.xsfg.cn
http://nowhither.xsfg.cn
http://www.hrbkazy.com/news/61283.html

相关文章:

  • 亳州公司做网站关键词优化
  • 建立网站需要钱吗朋友圈信息流广告投放价格
  • 网站建设验收需要注意什么国内ip地址 免费
  • 青岛平面设计公司手机管家一键优化
  • 网站怎么做单页日照网络推广公司
  • 虚拟机怎么做多个网站百度竞价ocpc
  • 可做兼职的翻译网站有哪些jmr119色带
  • 福建省住建厅建设网站推广网上国网
  • 查看网站建设的特点seo怎么做最佳
  • 西安建设工程信息网网上招投标sem优化
  • 佛山 网站建设培训班网站优化排名哪家好
  • 济宁正德网站建设网推软件有哪些
  • 国内网站放国外服务器站内seo优化
  • 可信网站注册湖南百度推广代理商
  • 东海县城乡建设局网站推广app赚佣金平台
  • 我电脑做网站局域网怎么访问中国职业培训在线官方网站
  • 杭州滨江网站建设公司短视频获客系统
  • 做网站需要执照嘛网络舆情分析报告范文
  • 网页设计模板代码网站手机系统优化工具
  • 未备案网站大一网页设计作业成品免费
  • 大同网站建设哪里好seo运营做什么
  • 怎么做qq可信任网站爱站小工具计算器
  • 手机交友网站源码福州seo排名优化公司
  • axure做的购物网站谷歌搜索引擎入口363
  • 网站开发运营公司查看别人网站的访问量
  • 网络设计公司排名企业站seo案例分析
  • 做英语quiz的网站谷歌seo搜索引擎下载
  • 网站如何取消验证码网络营销有哪些推广平台
  • 有什么专门做电子琴音乐的网站seo规则
  • 四川住房和城乡建设部官方网站社区营销推广活动方案