Developer forum

Forum » Dynamicweb 10 » Uninstalling AddIn doesn't unload the assembly - needs app restart

Uninstalling AddIn doesn't unload the assembly - needs app restart

Kevin Steffer
Kevin Steffer
Reply

I found out, that uninstalling an installed AddIns from /System/AddIns/Local doesn't unload the assembly.

I created a Notification Subscriber in my DLL

[Subscribe("DWN_STANDARD_PAGE_LOADED")]
  public class PageLoaded : NotificationSubscriber
  {
    public override void OnNotify(string notification, NotificationArgs args) => ((Standard.Page.LoadedArgs) args).PageViewInstance.Page.MetaTitle = "Custom Page Title";
  }

And even after Uninstalling my AddIn my pages still had the "Custom Page Title" until i restarted the application.

Shouldn't the uninstall take care of this?


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Kevin

This will happen if something has been build that holds on to a type in your package. E.g. if you reference a method from your custom package in a template, the template is build by razor engine and stored in memory as an instance of the template compilated type - and it will hold on to the reference to the type in your custom project.

We have explicitly tested for unloading notification subscribers when the dll is unloaded. But if this notification is part of a package that has other types that are e.g. referenced in a template that has not been cleared from cache, this will not unload until a recycle. 

We did change in some recent 10.3.* version - so it can be that this has been changed if you try on latest 10.3 or 10.4

 
Kevin Steffer
Kevin Steffer
Reply

I tested on 10.3.4 and made a Notification Subscriber that changes the Metatitle on PageLoad

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
 
Frederik Nielsen Dynamicweb Employee
Frederik Nielsen
Reply

Hi Kevin,

In this case, the addin is actually being unloaded successfully, however it's the page caching that is causing the issue you're seeing. Once you've set the title of the page, it will stay like that regardless of the addin existing or not, you can test and verify this by setting it to a new Guid instead;

[Subscribe("DWN_STANDARD_PAGE_LOADED")]
  public class PageLoaded : NotificationSubscriber
  {
    public override void OnNotify(string notification, NotificationArgs args) => ((Standard.Page.LoadedArgs) args).PageViewInstance.Page.MetaTitle = Guid.NewGuid().ToString();
  }

You would then see the following;

Install addin
1st load, original page title - after the page is loaded, the notification is made and the title is updated, but this is after the page is loaded.
2nd load, "d547f6c9-0fd7-49cd-9e4f-9d13a2b6cbae" - the page now has the guid it generated from the previous load, and it now generates a new one for the next load.
3rd load, "192a7564-7ca9-4090-8a72-800dc9a9fdf4" - same as above, but keep in mind that the pages actual title is different from what it was loaded in with.
Uninstall addin
4th load, "70392159-281a-4607-9e66-0101f036a8fc" - this is the new guid it got from the previous notification, but since there's no longer any notification subscriber setting the metaTitle, it will stay like this.
5th load and onward "70392159-281a-4607-9e66-0101f036a8fc" - same guid as above, as no new ones are generated.

I hope it makes sense - in general the pageView wouldn't really be modified like this and I get the point of this is getting to know and understand the addins etc, this is the reason for the behaviour you're seeing.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

If you instead set 

.PageViewInstance.Meta.Title = "Custom"

you will alter the pageview which is only alive for one view, where 

.PageViewInstance.Page.MetaTitle

Is hitting the page in the service cache as Frederik explains. (Cache can be reset from settings -> system -> developer -> cache

 

You must be logged in to post in the forum