After some hours of thorough digging, I discovered that System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey()
is being called by DevExpress and this method makes a call to Assembly.GetEntryAssembly()
, which happens to return null when called from within a unit test, and this makes DevExpress believe that its being used in designer mode, which indeed requires a valid license.
Having this clue, I managed to find a really underrated answer from user @Manjay that provides an elegant solution to this problem by using reflection. I took the liberty to provide the following slightly modified version of Jamie Cansdale's code, which can be found here:
public static void SetEntryAssembly()
{
if (Assembly.GetEntryAssembly() != null)
{
return;
}
Assembly assembly = Assembly.GetCallingAssembly();
AppDomainManager manager = new AppDomainManager();
FieldInfo entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
if (entryAssemblyfield != null)
{
entryAssemblyfield.SetValue(manager, assembly);
}
AppDomain domain = AppDomain.CurrentDomain;
FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
if (domainManagerField != null)
{
domainManagerField.SetValue(domain, manager);
}
}