2
有什么办法处置由下面的标记创建的对象的...处置由d创建的对象:DesignInstance
<UserControl x:Class="NodeBrowser"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="344" d:DesignWidth="589"
d:DataContext="{d:DesignInstance Type=local:NodeBrowserViewModel, IsDesignTimeCreatable=True}"
>
<Whatever...>
</UserControl>
我的设计实例创建这样我第一次到数据库的连接设计时间测试这个控件一切正常,但第二次它抛出一个异常,因为第一个设计时间数据仍然有一个开放的连接。
现在我知道这并没有什么意义,但它仍然引发了通过d:DesignInstance创建的对象似乎永远不会被丢弃的问题,即使它们实现了IDisposable。
有没有解决方案,或者我们基本上被迫提供不需要IDisposable设计数据的轻量级对象?