GlobalObject Class

 

Provides the base class for types whose instances are accessible for each project.

Namespace:   Microsoft.VisualStudio.Shell.Design
Assembly:  Microsoft.VisualStudio.Shell.Design (in Microsoft.VisualStudio.Shell.Design.dll)

System.Object
  System.MarshalByRefObject
    Microsoft.VisualStudio.Shell.Design.GlobalType
      Microsoft.VisualStudio.Shell.Design.GlobalObject

public abstract class GlobalObject : GlobalType

NameDescription
System_CAPS_protmethodGlobalObject(Type, String)

Initializes a new instance of the GlobalObject class.

NameDescription
System_CAPS_pubpropertyInstance

Gets an on-demand created instance of the global object.

System_CAPS_pubpropertyName

Gets the recommended name of the global object.

System_CAPS_pubpropertyObjectType

Gets the checked type of the GlobalType.(Inherited from GlobalType.)

NameDescription
System_CAPS_protmethodClearInstance()

Clears the Instance property.

System_CAPS_protmethodClearObjectType()

Clears the ObjectType property. (Inherited from GlobalType.)

System_CAPS_protmethodCreateInstance()

Creates a cached instance of the global object.

System_CAPS_pubmethodCreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodEquals(Object)

Checks if the specified object is equal to the current global object.(Overrides GlobalType.Equals(Object).)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Returns the hash code for the current global object.(Overrides GlobalType.GetHashCode().)

System_CAPS_pubmethodGetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_protmethodGetObjectType()

Returns the type of this global type.(Inherited from GlobalType.)

System_CAPS_pubmethodGetSerializer(Type)

Returns the checked serializer of the specified type for the global object.

System_CAPS_pubmethodGetSerializerCore(Type)

Returns a serializer of the specified type for the global object.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnChanged(EventArgs)

Raises the Changed event.(Inherited from GlobalType.)

System_CAPS_protmethodOnChanging(EventArgs)

Raises the Changing event.(Inherited from GlobalType.)

System_CAPS_protmethodOnCreated(EventArgs)

Raises the Created event.

System_CAPS_protmethodOnRemoved(EventArgs)

Raises the Removed event.(Inherited from GlobalType.)

System_CAPS_protmethodOnRemoving(EventArgs)

Raises the Removing event.(Inherited from GlobalType.)

System_CAPS_protmethodPerformChange()

Reinitializes the global object and notifies users to changes to its state or shape.(Overrides GlobalType.PerformChange().)

System_CAPS_protmethodPerformRemove()

Clears the global object and notifies users of its removal.(Overrides GlobalType.PerformRemove().)

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_pubeventChanged

Occurs after the current global type is modified.(Inherited from GlobalType.)

System_CAPS_pubeventChanging

Occurs before the current global type is modified.(Inherited from GlobalType.)

System_CAPS_pubeventCreated

Occurs when an instance of the global object is created.

System_CAPS_pubeventRemoved

Occurs after the current global type is removed from use.(Inherited from GlobalType.)

System_CAPS_pubeventRemoving

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.

Return to top
Show: