GlobalObject Class
Provides the base class for types whose instances are accessible for each project.
Assembly: Microsoft.VisualStudio.Shell.Design (in Microsoft.VisualStudio.Shell.Design.dll)
System.MarshalByRefObject
Microsoft.VisualStudio.Shell.Design.GlobalType
Microsoft.VisualStudio.Shell.Design.GlobalObject
| Name | Description | |
|---|---|---|
![]() | GlobalObject(Type, String) | Initializes a new instance of the GlobalObject class. |
| Name | Description | |
|---|---|---|
![]() | Instance | Gets an on-demand created instance of the global object. |
![]() | Name | Gets the recommended name of the global object. |
![]() | ObjectType | Gets the checked type of the GlobalType.(Inherited from GlobalType.) |
| Name | Description | |
|---|---|---|
![]() | ClearInstance() | Clears the Instance property. |
![]() | ClearObjectType() | Clears the ObjectType property. (Inherited from GlobalType.) |
![]() | CreateInstance() | Creates a cached instance of the global object. |
![]() | CreateObjRef(Type) | (Inherited from MarshalByRefObject.) |
![]() | Equals(Object) | Checks if the specified object is equal to the current global object.(Overrides GlobalType.Equals(Object).) |
![]() | Finalize() | (Inherited from Object.) |
![]() | GetHashCode() | Returns the hash code for the current global object.(Overrides GlobalType.GetHashCode().) |
![]() | GetLifetimeService() | (Inherited from MarshalByRefObject.) |
![]() | GetObjectType() | Returns the type of this global type.(Inherited from GlobalType.) |
![]() | GetSerializer(Type) | Returns the checked serializer of the specified type for the global object. |
![]() | GetSerializerCore(Type) | Returns a serializer of the specified type for the global object. |
![]() | GetType() | (Inherited from Object.) |
![]() | InitializeLifetimeService() | (Inherited from MarshalByRefObject.) |
![]() | MemberwiseClone() | (Inherited from Object.) |
![]() | MemberwiseClone(Boolean) | (Inherited from MarshalByRefObject.) |
![]() | OnChanged(EventArgs) | Raises the Changed event.(Inherited from GlobalType.) |
![]() | OnChanging(EventArgs) | Raises the Changing event.(Inherited from GlobalType.) |
![]() | OnCreated(EventArgs) | Raises the Created event. |
![]() | OnRemoved(EventArgs) | Raises the Removed event.(Inherited from GlobalType.) |
![]() | OnRemoving(EventArgs) | Raises the Removing event.(Inherited from GlobalType.) |
![]() | PerformChange() | Reinitializes the global object and notifies users to changes to its state or shape.(Overrides GlobalType.PerformChange().) |
![]() | PerformRemove() | Clears the global object and notifies users of its removal.(Overrides GlobalType.PerformRemove().) |
![]() | ToString() | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | Changed | Occurs after the current global type is modified.(Inherited from GlobalType.) |
![]() | Changing | Occurs before the current global type is modified.(Inherited from GlobalType.) |
![]() | Created | Occurs when an instance of the global object is created. |
![]() | Removed | Occurs after the current global type is removed from use.(Inherited from GlobalType.) |
![]() | Removing | Occurs before the current global type is removed from use.(Inherited from GlobalType.) |
A global object is an object that is accessible over an entire project, rather than just within a single application or a single form. For example, project-wide resource files provided in a Windows Forms application are global objects. Global objects have the following characteristics:
They are global to a project and are therefore single-instanced.
They are accessed by means of a static method or property on a class.
They are commonly custom types that are automatically generated by the project system.
They often change as a result of actions in other files within the project.
They can be marshaled from the default domain across other application domains because the GlobalObject class is derived from System.MarshalByRefObject. Marshaling requires that the global object instance be serializable.
While you perceive global objects as global, and this is also how they behave at runtime, at design time they are actually instanced for each designer. This enables the designers to maintain their own copies and remain isolated. The GlobalObjectService interacts with instances of GlobalObject in order to create these global object instances for each designer.
Global objects are not created directly; rather, a call to the GetGlobalObjects method of the GlobalObjectService class initiates a process that creates the desired global object instance.
GlobalObject also supports the creation of global types. A global type is a standard instanced object, but the type for this object comes from a project in the solution or from generated code. For more information about global types, see the base class GlobalType.
In the first version of the .NET Framework, types and instances were exposed through the existing project references system. Because this system uses real, compiled types it suffered from slower performance, duplicated data types, and the need to restart the designer environment when types were changed. Global types and virtual types were introduced in the second version of the Managed Package Framework to solve these problems. A virtual type enables the dynamic creation of a type and instances of that type based on an existing base class. Virtual types mimic ordinary compiled types when examined by the reflection application programming interface (API), but do not have a true class implementation. For more information about virtual types, see the VirtualTypeBuilder class.
The following code example shows some global objects.
DataSet cust = Customers.DefaultInstance; String error = MyAppResources.ErrorString; Bitmap logo = MyAppResources.ProductLogo;
The following code example shows some global types.
DataSet cust = new CustomerDataSet();
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



