0

I made a class library, COM visible, in CSharp with Visual Studio 2010. When I try to call this method:

    public string Version {
        get { return Assembly.GetEntryAssembly().GetName().Version.ToString(); }
    }

from VB6 client I obtain Object reference not set to an instance of an object. Other methods works properly. From .NET client all works fine!

What's wrong? Thanks, Luigi.

Gigi
  • 315
  • 7
  • 23

1 Answers1

8

Assembly.GetEntryAssembly() returns the assmebly that launched this .Net process (with Main())

In an unmanaged process, it will return null.

To get the assembly containing your code, use typeof(MyType).Assembly.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964