Description:
I have an application that uses your Skins Library. To reduce an installation's size, Office and Bonus skins are not included in it by default. I want to provide a capability to download the "Skins Pack" separately that would install the Office (DevExpress.OfficeSkins.vX.Y.dll) and Bonus (DevExpress.BonusSkins.vX.Y.dll) skins DLLs to my application's directory if a user wants them. How can I load these DLLs if they are present?
Answer:
To load DLLs dynamically use the static LoadFile method of the Assembly class. This is the standard class and you can find more information about it in the Assembly.LoadFile Method (String) MSDN help topic.
Then, all you need is to call the SkinManager's RegisterAssembly method. For more information, please see the Custom Skin Registration help topic.
Your final code can look like this:
C#public Form1()
{
InitializeComponent();
string fileName = "DevExpress.BonusSkins.v9.3.dll";
if (File.Exists(fileName))
{
Assembly SampleAssembly = Assembly.LoadFile(Path.GetFullPath(fileName));
DevExpress.Skins.SkinManager.Default.RegisterAssembly(SampleAssembly);
}
else MessageBox.Show("File not found");
}
Visual BasicPublic Sub New()
InitializeComponent()
Dim fileName As String = "DevExpress.BonusSkins.v9.3.dll"
If File.Exists(fileName) Then
Dim SampleAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile(Path.GetFullPath(fileName))
DevExpress.Skins.SkinManager.Default.RegisterAssembly(SampleAssembly)
Else
MessageBox.Show("File not found")
End If
End Sub