I am developing an outlook plugin.I added a button in outlook toolbar, and when the user clicks that button, a webservice is called.Depending upon the result of that webservice a usercontrol is loaded in a custom task pane.When a user closes the custom task pane, I call the dispose method on the user control.I also dispose the child control of this user control in its disposed event and removed the custom task pane from the customtaskpanes list.But the memory is not released.I also disposed the custom task pane.But nothing happened.So, is it a problem with my coding, or is it a problem with outlook?I am working with winforms on .net framework 3.5.The memory taken by outlook keeps on increasing whenever I press the button.
It is hard to tell if a memory leak occurs without any code sample. Keep in mind that analyzing managed memory can be tricky...
However, my suggestion is that you probably should not dispose your VSTO task pane controls manually. If the user clicks the hide task pane, the task pane is not "destroyed" and you should not unregister it. Its Visible property is set to false
. See sample code below in my Startup.addin.cs that enables to Toggle the TaskPane visibility.
public const string productName = "myMillionDollarAddin";
private void RegisterTaskPane()
{
var tskControl = new TaskPaneControl();
CustomTaskPane taskPane = this.CustomTaskPanes.Add(tskControl, productName);
taskPane.Visible = true;
}
public void ShowHideTaskPane()
{
var taskPane = this.CustomTaskPanes.FirstOrDefault(ctp => ctp.Title == productName);
if (taskPane == null)
{
RegisterTaskPane();
}
else
{
var visibility = taskPane.Visible;
taskPane.Visible = !visibility;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments