c# - Can I suppress this message? >> One or more applications are using the iTunes scripting interface -
i writing small c sharp program interface itunes using itunes windows com api. program has running before itunes starts , after itunes closes down. want detect when itunes closes down using onquittingevent.
private void itunes_onquittingevent() { // remove handlers itunes com object. app.onplayerplayevent -= itunes_onplayerplayevent; app.onquittingevent -= itunes_onquittingevent; bnitunesrunning = false; // release com object. app = null; console.writeline("itunes closing!"); }
however c sharp program running, when close down itunes warning message: "one or more applications using itunes scripting interface" , 20 second countdown before itunes closes.
my question: can use itunes windows com onquittingevent event handler sort of un-instantiate itunesapp object reference in c sharp code @ point of me closing down itunes application , not have warning message appear on screen?? there way suppress warning message altogether?
a similar question asked here: how suppress "there still active com objects in application" error when closing application? code c++ not c sharp.
thank you.
to prevent dialog need decrement runtime callable wrapper reference count, , force collection of itunesappclass reference. more detail see post user bonj here. unlike in example found wasn't necessary set itunesappclass reference null before collecting. might depend on implementation however. found didn't have decrement rcw in loop ever have 1 com object referenced. here's example works in application:
var app = new ituneslib.itunesappclass(); // stuff system.runtime.interopservices.marshal.releasecomobject(app); system.gc.collect();
Comments
Post a Comment