Share via


HostedEventProvider Constructor (Application, String)

Initializes a new instance of the HostedEventProvider class with an Application and a name.

Namespace: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Syntax

'Declaration
Public Sub New ( _
    application As Application, _
    name As String _
)
public HostedEventProvider (
    Application application,
    string name
)
public:
HostedEventProvider (
    Application^ application, 
    String^ name
)
public HostedEventProvider (
    Application application, 
    String name
)
public function HostedEventProvider (
    application : Application, 
    name : String
)

Parameters

  • application
    The parent Application for the event provider. This parameter sets the Parent property.
  • name
    A String, between 1 and 255 characters in length, that specifies the name of the hosted event provider. The name must be unique within the application.

    You cannot change the name. To rename a hosted event provider, remove the provider and then add another.

Remarks

Updated text:5 December 2005

Using this constructor, the default StartTime value is DateTime.MinValue and the default Timeout is 5 minutes.

Example

The following examples show how to define a hosted event provider:

// Define a hosted event provider
HostedEventProvider flightEventProvider = 
    new HostedEventProvider(myApplication, "FlightEP");
flightEventProvider.ClassName = "FileSystemWatcherProvider";
flightEventProvider.SystemName = notificationServicesHost;

// Define event provider arguments
HostedEventProviderArgument fileArg_Directory = 
    new HostedEventProviderArgument(
    flightEventProvider, "WatchDirectory");
fileArg_Directory.Value = sampleDirectory + @"\Events";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_Directory);

HostedEventProviderArgument fileArg_Schema = 
    new HostedEventProviderArgument(
    flightEventProvider, "SchemaFile");
fileArg_Schema.Value = sampleDirectory + 
    @"\AppDefinition\EventsSchema.xsd";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_Schema);

HostedEventProviderArgument fileArg_EventClass = 
    new HostedEventProviderArgument(flightEventProvider, 
    "EventClassName");
fileArg_EventClass.Value = "FlightEvents";
flightEventProvider.HostedEventProviderArguments.Add(
    fileArg_EventClass);

myApplication.HostedEventProviders.Add(flightEventProvider);
' Define a hosted event provider
Dim flightEventProvider As HostedEventProvider = _
    New HostedEventProvider(myApplication, "FlightEP")
flightEventProvider.ClassName = "FileSystemWatcherProvider"
flightEventProvider.SystemName = notificationServicesHost

' Define event provider arguments
Dim fileArg_Directory As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
        "WatchDirectory")
fileArg_Directory.Value = sampleDirectory + "\Events"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_Directory)

Dim fileArg_Schema As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
        "SchemaFile")
fileArg_Schema.Value = sampleDirectory + _
    "\AppDefinition\EventsSchema.xsd"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_Schema)

Dim fileArg_EventClass As HostedEventProviderArgument = _
    New HostedEventProviderArgument(flightEventProvider, _
    "EventClassName")
fileArg_EventClass.Value = "FlightEvents"
flightEventProvider.HostedEventProviderArguments.Add( _
    fileArg_EventClass)

myApplication.HostedEventProviders.Add(flightEventProvider)

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

HostedEventProvider Class
HostedEventProvider Members
Microsoft.SqlServer.Management.Nmo Namespace

Other Resources

Defining Hosted Event Providers
HostedProvider Element (ADF)