Programmatically Deleting an Instance
i'm trying basic ns app , running. while can through samples fine, seems there no samples programmatically manage instances/applications, etc. i've googled around , not found either. looks me uses idf/adf files. sdk has sparse documentation on it, i've started there , tried things working.
i have code create instance/application programmatically, when want drop whole thing , create again, upon calling instance.create() exception (actually innerexception says) saying:
notification services failed read nsversioninfo table.
i’m following example in sdk (doing disable/unregisterlocal/drop). interestingly when disable/unregister/drop in sql management studio works fine. it's interesting note when ignore exception comes once more, after instance , associated databases seem created.
here’s short version of code (getfreshinstance() is entry method):
private void configureinstance(nmo.instance instance)
{
prototypeapplication = new nmo.application(instance, applicationname);
adddeliverychannels(instance);
configureapp(prototypeapplication);
instance.applications.add(prototypeapplication);
}
private void configureapp(nmo.application app)
{
addgenerator(app);
adddistributor(app);
}
private void checkanddrop(string name)
{
if (notificationservices.instances.contains(name))
{
nmo.instance instance = new nmo.instance(notificationservices, name);
instance.refresh();
instance.disable();
instance.unregisterlocal();
instance.drop();
}
}
private nmo.instance getfreshinstance()
{
nmo.instance instance = new nmo.instance(notificationservices, instancename);
checkanddrop(instancename);
configureinstance(instance);
instance.create();
instance.registerlocal();
instance.enable();
return instance;
}
anyone know i'm doing wrong?
ok, seems you've asked question not many folks in wild know answer :-).
i've tracked down what answer care of shyam pather:
he’s creating new in-memory object reflect instance, this:
nmo.instance instance = new nmo.instance(…, “instancename”);
instead, should like:
smo.server s = new smo.server(…);
nmo.instance instance = s.notificationservices.instances[“instancename”];
that him instance object that’s populated metadata database , actually represents existing instance.
the flightnmo sample comes sql server 2005 should provide working example of how make api calls.
hope helps,
-lukasz
---
this posting provided "as is" no warranties, , confers no rights.
SQL Server > SQL Server Notification Services
Comments
Post a Comment