使用COM包装器调用.NET dll (mclNET.dll)有问题。这是第三部分dll,我没有源代码。基本上,我想在我的纯原生应用程序中使用这个mclNET.dll,所以我正在开发一个C#包装器。MCLWrapper.dll,,使mclNET.dll中的方法可见。以下是我所做的:
这是AssemblyInfor.cs for MCLWrapper.dll:
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MCLWrapper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MCLWrapper")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//[assembly: AssemblyKeyFile("..\\MCLWrapper.SNK")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("14fa8796-ee52-4e39-8481-f893ad92bb68")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]现在的问题是,它不识别MySwitch->MCLSet_Switch(&_A,&output)函数,这意味着mclNET.dll还没有完全暴露在我的本机C++代码中。
我想知道这里有什么问题?我怎么可能纠正它呢?如何在我的本机.NET应用程序中调用C++ dll?首先非常感谢。
发布于 2013-05-14 16:43:56
我终于解决了这个问题。我想我基本上做了两件事:
也许我在以前的项目中搞砸了一些事情,但我没有意识到。也许是新的NET.dll做了这个魔术。我没有头绪。我基本上重复了我做过的事情,但这次非常干净。
不知怎么我让它起作用了。因此,基本上,我最初的线程主要是如何从本机.NET代码调用C++ dll。希望我的经历能对你有所帮助。
发布于 2013-05-14 16:43:09
#import <mscorlib.tlb> raw_interfaces_only
#import C:/MyPath/MCLWrapper.tlb" no_namespace named_guidsTry是上面提到的导入语句--为我工作,并调用您的.net代码,而不需要从本地C++调用任何名称空间。
https://stackoverflow.com/questions/16546667
复制相似问题