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)

Syntax

‘선언
Public MustInherit Class GlobalObject _
    Inherits GlobalType
‘사용 방법
Dim instance As GlobalObject
public abstract class GlobalObject : GlobalType
public ref class GlobalObject abstract : public GlobalType
[<AbstractClassAttribute>]
type GlobalObject =  
    class
        inherit GlobalType
    end
public abstract class GlobalObject extends GlobalType

Remarks

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.

Examples

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();

Inheritance Hierarchy

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

GlobalObject Members

Microsoft.VisualStudio.Shell.Design Namespace

GlobalObjectService

GlobalObjectProvider

GlobalObjectProviderFactory

ProvideGlobalObjectProviderAttribute

VirtualTypeBuilder