programmatically Disable addin

  • Thread starter Thread starter shubhangi
  • Start date Start date
S

shubhangi

hello
I want to disable my addin if certain condition is not met(licence etc.).How
to do this programmatically?I'm using VSTO SE for Outlook 2007.Besides this
I don't want to show
form regions if that condition is not met.If the condition is met then only
my addin is required to
enable & form regions to be shown.Can this be done programmatically?
thanks
 
Check your license information and if it fails then call to whatever code
you have running when you get the Shutdown() event. You might have to hack
the registry also to remove any form region information.
 
Thanks Ken.I did
1.In Application_startup I checked licence and added
Application.COMAddIns.Item("MyAddIn").Connect=False.
2.For not displaying form regions -
Protected Overrides Function RequestService(ByVal serviceGuid As Guid)
As Object
If serviceGuid =
GetType(Microsoft.Office.Interop.Outlook.FormRegionStartup).GUID Then
If gblbLicence = False Then Return Nothing
ObjFormRegion = New FormRegionHookupVB(Me.Application)
'FormRegionHookupVB implements formregionstartup interface
Return ObjFormRegion
End If
Return MyBase.RequestService(serviceGuid)
End Function
will it have any problem with form region?
Thanks again
 
That should be OK, but be aware that if the user opens an item with the
message class specified in the registry for your form region that your addin
will become enabled and start from the Startup() event all over again. The
only way to prevent that would be to hack the registry and delete your entry
for the form region.

I'd probably write out the form region information to the registry if the
license check passed and delete it if the license test failed.
 
Thanks again
You are right,the loadbehavior resets again to 3 though
Application.COMAddIns.Item("MyAddIn").Connect=False.
is given in Application_Startup as Form region related entries are present
in registry.
I removed the form region related entries from registry if licence
evaluation failed & added the
same if licence evaluation succeeded as per ur suggestion.Now the addin
remains disabled & form region also not shown.
Thanks once again!
 
Back
Top