Sam
Sam

Reputation: 29009

Get .NET assembly by type in C++

To get an assembly from a type in c# I'd use the following

typeof(MyTypeOrClass).Assembly

But how do I achieve this in C++?

Upvotes: 0

Views: 151

Answers (1)

Jochen Kalmbach
Jochen Kalmbach

Reputation: 3684

You can do it by using "typeid":

using namespace System;

namespace NS
{
  public ref class Foo
  {
  };
}
int main()
{
  System::Reflection::Assembly^ a = NS::Foo::typeid->Assembly;
  Console::WriteLine(a);
}

Upvotes: 1

Related Questions