How to debug regasm (what types get registered)

258 Views Asked by At

We have a Managed C++ DLL that when registered with regasm appears to add some junk types to the registry. Within the class Blah, any private variables utilizing MyTeam.ManagedAutoPtr get added to the registry. My question at this point is whether it's possible to debug exactly why something is added to the registry? regasm /verbose was not helpful

    [HKEY_CLASSES_ROOT\MyTeam.ManagedAutoPtr<MyTeam::CustomType>]
@="MyTeam.ManagedAutoPtr<MyTeam::CustomType >"

[HKEY_CLASSES_ROOT\MyTeam.ManagedAutoPtr<MyTeam::CustomType >\CLSID]
@="{039DEE72-0D73-3DCC-84AC-900E6F734715}"

[HKEY_CLASSES_ROOT\CLSID\{039DEE72-0D73-3DCC-84AC-900E6F734715}]
@="MyTeam.ManagedAutoPtr<MyTeam::CustomType>"

[HKEY_CLASSES_ROOT\CLSID\{039DEE72-0D73-3DCC-84AC-900E6F734715}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="MyTeam.ManagedAutoPtr<MyTeam::CustomType>"
"Assembly"="BlahsNamespace.Blah, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v4.0.30319"

The relevant part of Blah is:

public ref class Blah
{
    private:
        MyTeam::ManagedAutoPtr<MyTeam::CustomType> _variable;
}

And finally this is ManagedAutoPtr in its entirety

template <typename T> public ref class ManagedAutoPtr {
  // This implementation is taken from 
  // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/CplusCLIBP.asp

public:
  /**
   * Constructs an zero pointer.
   */
  ManagedAutoPtr() : _p(0) {}

  /**
   * Constructs a pointer that references the given T instance. This
   * ManagedAutoPtr will take ownership of @a *ptr.
   */
  ManagedAutoPtr(T* ptr) : _p(ptr) {}

  /**
   * Constructs a pointer that references the same T instance as @a other. 
   * This ManagedAutoPtr will take over the ownership of the T instance,
   * while @a other will lose it. @a other may represent a zero pointer.
   */
  ManagedAutoPtr(ManagedAutoPtr<T>% other) : _p(other.release()) {}

  /**
   * Constructs a pointer that references the same T instance as @a other. 
   * This ManagedAutoPtr will take over the ownership of the T instance,
   * while @a other will lose it. @a other may represent a zero pointer.
   */
  template<typename Derived> 
  ManagedAutoPtr(ManagedAutoPtr<Derived>% other) : _p(other.release()) {}

  /**
   * Constructs a pointer that references the same T instance as @a other. 
   * This ManagedAutoPtr will take over the ownership of the T instance,
   * while @a other will lose it. @a other may represent a zero pointer.
   */
  template<typename Derived> 
  ManagedAutoPtr(esp::auto_ptr<Derived>& other) : _p(other.release()) {}

  /**
   * A finalizer that deletes any T instance that it might still hold.
   */
  !ManagedAutoPtr() {
    delete _p;
    _p = 0;
  }

  /**
   * Destroys this ManagedAutoPtr, and deletes any T instance it might
   * reference.
   */
  ~ManagedAutoPtr() {
    this->!ManagedAutoPtr();
  }

  /**
   * Returns a raw pointer to the T instance referenced by this
   * ManagedAutoPtr, if any.
   */
  T* get() {
    return _p;
  }

  /**
   * Causes this ManagedAutoPtr to lose its ownership of the T
   * instance that it is referencing (if any). A raw pointer to this T
   * instance will be returned (or the zero pointer if this ManagedAutoPtr
   * did not own any T instance).
   */
  T* release() {
    T* released = _p;
    _p = 0;
    return released;
  }

  /**
   * Causes this ManagedAutoPtr to take ownership of the T instance
   * pointed to by @a ptr. The T instance currently owned by this
   * ManagedAutoPtr (if any) will be deleted. @a ptr may be zero.
   */
  void reset(T* ptr) {
    if (ptr != _p) {
      delete _p;
      _p = ptr;
    }
  }

  /**
   * Sets this ManagedAutoPtr to zero. The T instance owned
   * by this ManagedAutoPtr (if any) will be deleted.
   */
  void reset() {
    reset(0);
  }

  /**
   * Returns a reference to the T instances owned by 
   * @a autoPtr.
   *
   * @pre autoPtr.get() != 0
   */
  static T& operator*(ManagedAutoPtr<T>% autoPtr) { 
    return *autoPtr._p; 
  }

  /**
   * Returns a non-zero raw pointer to the T instance referenced by this
   * ManagedAutoPtr.
   *
   * @pre get() != 0
   */
  static T* operator->(ManagedAutoPtr<T>% autoPtr) {
    ESP_ASSERT(autoPtr._p != 0);
    return autoPtr._p;
  }  

  /**
   * Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
   * the T instance, and this ManagedAutoPtr gains the ownership. 
   */
  ManagedAutoPtr<T>% operator=(ManagedAutoPtr<T>% other) {
    if (this != %other) {
      reset(other.release());
    }
    return *this;
  }

  /**
   * Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
   * the T instance, and this ManagedAutoPtr gains the ownership. 
   */
  template<typename Derived>
  ManagedAutoPtr<T>% operator=(ManagedAutoPtr<Derived>% other) {
    reset(other.release());
    return *this;
  }

  /**
   * Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
   * the T instance, and this ManagedAutoPtr gains the ownership. 
   */
  template<typename Derived>
  ManagedAutoPtr<T>% operator=(esp::auto_ptr<Derived>& other) {
    reset(other.release());
    return *this;
  }

private:
  T* _p;
};
1

There are 1 best solutions below

0
Mijin On

Doh, found it, the relevant tool is ildasm (also within VS command prompt). Wealth of info on what types are in the assembly.