0

I am trying to add an unmanaged C++ dll to a managed (CLI) C++ dll project. When I click the "class wizard," I get a "MFC classes can only be added to MFC projects" error message. I am not using MFC, to the best of my knowledge (Use of MFC is blank under my unmanaged dll's project page). Is there another way to add an unmanaged dll to my managed dll's project?

For anyone who is interested, I've thrown the rared solution up on my DropBox account: https://dl.dropbox.com/u/98752313/CplusplusArrayTest.rar

I realize there are far too many settings that could be wrong for me to simply copy and paste everything into the available space.

There are three projects within this solution. CplusplusArray (should be complete, it's the unmanaged .dll), ManagedCpluspplusArray (need to add the unmanaged dll, and modify a few things, it's the managed .dll), and a C# test program (not written yet, will hopefully talk to the unmanaged dll through the managed dll).

The whole goal of this project, if you are wondering, is to give C# the ability to use arrays with longs as the indexers. If you've used any amount of .Net before, you may have run into the Int32/Uint32 limit on the size of objects in the CLR. I am hoping to get around that by implementing the array in C++ land, then modifying / compiling some Mono Collections.Generics classes against it, thus giving us some breathing room. The reason I am doing C# -> C++/CLI -> C++ is so that, according to my research, we can use object oriented code with it; the DllImport stuff works fine for C-like functions only, and I want to preserve OOP, rather than modify things to work C-like. Since arrays are the building blocks of the List / etc. classes, from what I can tell, of the Collections namespace, getting just them to function in 64-bit land will give us everything else.

4

1 に答える 1

1

新しいクラスではなく、新しいプロジェクトを追加する必要があります。「プロジェクトを追加」すると、追加するプロジェクトの種類を尋ねられ、プレーンな C++ DLL がオプションの 1 つになります。

ソリューションに両方のプロジェクト (C++/CLI DLL プロジェクトと C++ DLL プロジェクト) があれば、ワークスペースの依存関係に移動して、一方が他方に依存していることを示すことができます。


その他の注意事項:

Class Wizard は、MFC クラスを追加するためのものです。MFC クラスの追加には関心がないため、これは適切なツールではありません。

ネイティブ C++ DLL を使用する C++/CLI DLL を作成したとき、C++ DLL のインポート ライブラリにリンクするための命令を追加する必要がありました。これは、
「プロジェクト プロパティ > 構成プロパティ > リンカー > 入力 > 追加の依存関係」で構成されました。

ワークスペースの依存関係により、アンマネージド ライブラリが最初にビルドされ、アンマネージド ライブラリが更新された場合、必要に応じてマネージド ライブラリが再コンパイルまたは再リンクされることが保証されます。

于 2012-12-13T00:32:53.490 に答える