locked
Why two Guids for ToolWindows? RRS feed

  • Question

  • In a VSPackage project the Package class has an attribute that says [ProvideToolWindow(typeof(MyToolWindow))]. 

    MyToolWindow is just a class so therefor it has a type and a Guid that is used by the attribute. But when you look in the class definition of MyToolWindow it has another attribute that defines a Guid.

    Why is that? Is it the same or is there a reason for two Guids?


    Thanks : )

    Tuesday, May 24, 2011 1:28 AM

Answers

  • The attribute is used by tooling that creates registry information that is necessary for VS to find your package/toolwindow.  The GUID property on your Type will pull its value from the GuidAttribute if present, otherwise it either uses Guid.Empty or generates one. I can't recall which, but I think the former, or I suppose it could do the latter at compile time, but it couldn't reasonably do it at runtime as the Guid generally needs to be stable across executions.

    Ryan

    Tuesday, May 24, 2011 5:48 AM

All replies

  • The attribute is used by tooling that creates registry information that is necessary for VS to find your package/toolwindow.  The GUID property on your Type will pull its value from the GuidAttribute if present, otherwise it either uses Guid.Empty or generates one. I can't recall which, but I think the former, or I suppose it could do the latter at compile time, but it couldn't reasonably do it at runtime as the Guid generally needs to be stable across executions.

    Ryan

    Tuesday, May 24, 2011 5:48 AM
  • Thank you so much! Just what I needed to know.
    Tuesday, May 24, 2011 2:21 PM