【问题标题】:Where can I find the declaration of mscorlib::_AppDomain, mscorlib::_Type etc在哪里可以找到 mscorlib::_AppDomain、mscorlib::_Type 等的声明
【发布时间】:2015-12-04 01:28:22
【问题描述】:

我正在使用它作为我的基地https://code.msdn.microsoft.com/CppHostCLR-e6581ee0/sourcecode?fileId=21953&pathId=1366553273

但在我的 VS2010 中,我无法获得智能感知或去声明。我尝试了 google,但它会将我带到 .NET 文档。

例如,我无法获取参数(或找到其声明的位置): spDefaultAppDomain->Load_2(bstrAssemblyName, &spAssembly);

_AppDomainPtr spDefaultAppDomain = NULL; _AppDomainPtr 基本上就是 mscorlib::_AppDomain..

抱歉,由于我在这种类型的编码方面没有太多经验,所以我不知道如何正确地提出问题。

【问题讨论】:

  • 这是 CLR Hosting (Unmanaged API) 的一部分。您需要了解Component Object Model (COM)。没有捷径。
  • 我希望人们可以在 cmets 中告诉我他们为什么投反对票,这里不乏“我在哪里可以找到”的问题,所以我不明白,也无法改进,因为没有人在 cmets 中写任何东西关于它。
  • 关于 stackoverflow 的好问题解决了常见的编程问题。不了解 COM 并尝试使用它不会引出好的问题。这个问题就是一个很好的例子。您询问的是非常基本的信息,这些信息很容易获得(例如,请参阅 COM, DCOM, and Type Libraries)。

标签: c++ winapi clr clr-hosting


【解决方案1】:

我找到了答案here

这是这个例子的声明方式:

#pragma comment(lib, "mscoree.lib")
#import "mscorlib.tlb" raw_interfaces_only\
            high_property_prefixes("_get","_put","_putref")\
            rename("ReportEvent", "InteropServices_ReportEvent")
using namespace mscorlib;

我已经在 VS2017 中对此进行了测试,对于此编译器,请务必在 C/C++/Language 设置中将 Conformance mode 设置为 No 以使其正确编译。

【讨论】:

  • 将一致性模式更改为否后出现错误cannot open source file mscorlib.tlh。否则在 mscorlib.tlh 中出现enum type is nonstandard
【解决方案2】:

您可以使用 OLEView.exe 并在导航窗格中向下滚动到类型库,找到正确的类型库,右键单击并单击查看,有声明。

【讨论】:

    猜你喜欢
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多