没人感兴趣吗?可以不断加分的具体情况是,访问数据库的所有函数都封装在C#写的一个DLL库里,我想通过VC.net调用这个动态库,访问数据库!好像和VC没什么关系,不过我以前一直在这里,知道这里高人多,版主不要删,谢谢了
解决方案 »
- 各位高人,能不能帮小弟把C#的代码转 VB.NET
- .net g.DrawImage 坐标负值没有作用
- C# pdf控件AxAcroPDFLib 资料收集,凡提供有用的资料,均加分
- 自己定义的空间引用说找不到
- 求救!!!更新remoting 起用的程序集,有没有办法不用重启remoting server ?
- 如www.163car.com左边的即使通上,菜单上的动态数据(部门和部门下的人,部门数及其下的人数都变),在ASP。NET中怎么加载上去?
- 在c#中网页文本框存储的格式,在读取时依然是原来存入的格式呀
- 请问C# WebBrowser 怎么获取 多次重定向后的 目标地址呢?
- CSDN大神求助
- C#解析pcap文件
- C#下如何实现窗体停靠
- c#怎样使用资源文件????????
application ?
You have to choices:
1- You use the COM interop features of .NET to expose your C# classes as com
objects, and use those from C++.
2- Create a wrapper library in managed C++ and use that.Is it possible to call C# DLL (or managed C++ DLL ) in a
Win32 application in C++ (standard) ?I can't call a managed C++ DLL in a classic C++ DLL
because my managed C++ DLL contains some directives
unknown by C++ like : "use namespace System" or "__gc" ...
Please, help meYou'll probably have to put the C# DLL in a COM callable
wrapper first which may require some work in exposing the
proper interface. You'll also have to use the tlbexp tool
to create a type library and the regasm tool to add a
reference to the DLL in the registry.
Hope that helps get you started!我的观点是:managed C++ 能直接调用C#的dll吧?
stored in a VC++ DLL with C#? How? If you are talking about plain old C++ classes (not COM classes or
managed classes) then no, it is not possible. This doesn't mean that the
DLL can't use classes internally, but if it was to pass a pointer out to
.NET (through an IntPtr), then it would be worthless.If you have the .LIB and .H for this .DLL,
you could write wrappers with the Managed Extension for VC++.If the question is:
Can I create an instance of a unmanaged C++ class and call appropriate methods exposed by this class?The answer is you can't unless you are prepared for a change the C++ class.1. You need to specify CallingConvention.ThisCall in the DllimportAttribute.
2. You need to specify the ordinal number as entry
3. You need to add a class factory method to your C++ dll in order to create an instance of a C++ class
4. You need to keep a list of outstanding references
5 You need to explicitly destroy the owned instance from C#If you compare this to the creation of a managed wrapper, the latter is definitely the way to go.这些来自新闻组,希望对你有用。
分数是小事情,如果成功了分享一下经验。
所以,VC.NET如何调用VC.NET的Assembly,就如何调用C#的Assembly,no difference:不外乎加reference引用而已——当然,Assembly必须在Local Direcotry正确部署,或者安装到GAC中。
如果你用的是VC.NET的unmanaged属性,那就像CForce说的那样做——不过,现在写程序何必非要进到unmanaged部分呢?至少在Assembly的接口部分可以采用VC.NET的Managed代码,VC.NET是允许混合编程的,这样可维护性就好多了。
我用C#自定义的控键, 编译后是DLL,然后在VB.NET中调用的时候,只要 自定义工具箱——> .NET框架组件——>浏览 再加入哪个编译生成的DLL 就可以了 可惜我说的是自定义组件,不是DLL !:)