We have a custom control. Some properties of this control use custom type converters and UI type editors, and they are implemented in a separate design-time DLL. These type converters are defined using the string syntax of the TypeConverter and Editor attributes, for example:
[TypeConverter("<full class name>, <library name>, Version=<version>")]
public CustomType Property1
{
// property implementation
}
When we display the properties of our custom control in the standard PropertyGrid control from the WinForms package in a compiled app, the corresponding type converters and UI type editors from our design-time DLL are found only when we place this DLL in the folder containing the application exe. We do not want to duplicate the design-time DLL in this folder for some reasons. Is there any other way to tell the PropertyGrid control where it can find the design-time DLL referenced this way?
You can use either of the following options:
Install the assembly in GAC and decorate the property like this (use your assembly fully qualified name). As already mentioned in the comments by Hans, I also believe it's the most decent way:
Copy the assemblies to your application folder and decorate the property like this.
In case of having a known location for assemblies, you can handle
AppDomain.AssemblyResolveevent and load the assembly. For example, assuming there is anassembliesfolder under your application folder which contains the assembly, you can add the following code to your main method beforeApplication.Run:I assume you have the property declaration:
As already mentioned in the comments by TnTinMn, In case of having a known location for assemblies, you can also load assemblies without writing code, by registering the known folder in your app.config using
probingtag orcodebasetag. For example, assuming there is anassembliesfolder under your application folder which contains the assembly:I assume you have the property declaration: