我正在尝试将我的插件dll加载到单独的AppDomain中,但Load()方法因FileNotFoundException而失败.而且,似乎设置AppDomainSetup的PrivateBinPath属性没有任何效果,因为在日志中我看到"Initial PrivatePath = NULL".所有插件都有很强的名字.通常,每个插件都存储在[Application startp path]\postplugins\[plugindir]中.如果我将plugins子目录放在[Application startp path]目录下,一切正常.我也试图手动更改AppBase属性但它没有改变.
这是代码:
public void LoadPostPlugins(IPluginsHost host, string pluginsDir)
{
_Host = host;
var privatePath = "";
var paths = new List<string>();
//build PrivateBinPath
var dirs = new DirectoryInfo(pluginsDir).GetDirectories();
foreach (var d in dirs)
{
privatePath += d.FullName;
privatePath += ";";
}
if (privatePath.Length > 1) privatePath = privatePath.Substring(0, privatePath.Length - 1);
//create new domain
var appDomainSetup = new AppDomainSetup { PrivateBinPath = privatePath };
Evidence evidence = AppDomain.CurrentDomain.Evidence;
var …Run Code Online (Sandbox Code Playgroud) 我编写了简单的WPF自定义文本框控件来保存小数值.这是一个非常"轻"的代码版本,没有大多数方法和属性(但它应该足以进行测试):
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace CustomControls
{
public class NumericBox : TextBox
{
public static readonly DependencyProperty ValueProperty;
public static readonly DependencyProperty DecimalCountProperty;
static NumericBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericBox), new FrameworkPropertyMetadata(typeof(NumericBox)));
ValueProperty = DependencyProperty.Register("Value", typeof (decimal?), typeof (NumericBox),
new FrameworkPropertyMetadata(0m, OnValueChanged));
DecimalCountProperty = DependencyProperty.Register("DecimalCount", typeof(int), typeof(NumericBox),
new FrameworkPropertyMetadata(2, OnDecimalCountChanged));
}
public int DecimalCount
{
get { return (int)GetValue(DecimalCountProperty); }
set { SetValue(DecimalCountProperty, value); }
}
public decimal? Value
{
get { return (decimal?)GetValue(ValueProperty); }
set …Run Code Online (Sandbox Code Playgroud)