不能从另一个项目中使用dll中的一个类的类型定义

Cant use typedef of one class in dll from another project

本文关键字:一个 定义 类型 项目 不能 dll 另一个      更新时间:2023-10-16

我写了一个dll,其中我有namespace VT在witch class public ref class Database在witch我有typedefs:

public:
        typedef System::Collections::Generic::Dictionary <System::String^, Database^>         SubkeyDictionary;
        typedef System::Collections::Generic::Dictionary <System::String^, System::Object^>   ValueDictionary;
        typedef System::Collections::Generic::KeyValuePair <System::String^, Database^>       SubkeyKeyValuePair;
        typedef System::Collections::Generic::KeyValuePair <System::String^, System::Object^> ValueKeyValuePair;

当我将我的dll添加到另一个项目并写VT::我看不到我的类型,为什么?

一个类型集更像是一个别名,而不是一个实际的类型,我将很快检查,但我怀疑这不是作为一个可以从其他程序集使用的。net类型公开的。

然而,并不是所有的都输了。除了使用排版,您还可以执行以下操作

public:
  ref class SubkeyDictionary : public System::Collections::Generic::Dictionary <System::String^, Database^> {};
....

类型定义在类中,而不是名称空间中。写

VT::Database::