Hi Sebastien,
I also found it doesn't work in run-time, after some research, I found this
problem is caused by an assembly resolve failer when propertygrid trying to
get the type from the Typename. You need write the full qualified type name
in Editor Attribute if you want to use the StringDictionaryEditor in
run-time, there are two ways to solve this problem:
1. re-write the Editor Attribute definition as :
Editor("System.Diagnostics.Design.StringDictionaryEditor, System.Design,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Drawing.Design.UITypeEditor,System.Design, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"))
Or a bit simpler if you reference the System.Design Assembly
Editor("System.Diagnostics.Design.StringDictionaryEditor, System.Design,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(System.Drawing.Design.UITypeEditor))
2. If you would like to use some more flexible way to instantiate this type
(e.g. for different versions)
You may handle the AppDomain.AssemblyResolve event and provide your own
assembly resolve implementation, here is skeleton for this:
//keep the Editor Attribute as previous
//Editor("System.Diagnostics.Design.StringDictionaryEditor, System.Design",
//"System.Drawing.Design.UITypeEditor,System.Drawing")
//AppDomain.CurrentDomain.AssemblyResolve +=new
ResolveEventHandler(CurrentDomain_AssemblyResolve);
private static Assembly CurrentDomain_AssemblyResolve(object sender,
ResolveEventArgs args)
{
if (args.Name == "System.Design")
{
Assembly asm = Assembly.Load("System.Design, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
return asm;
}
if (args.Name == "System.Drawing")
{
Assembly asm = Assembly.Load("System.Drawing, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
return asm;
}
return null;
}
Does it work for you?
Please let me know if you still have problem on it.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.