Hi Andred,
The MANAGED flag has to be set to one only if you are dealing with a managed (ie .Net) dll. The demand loading mechanism happens at a time AutoCAD may not be fully initialized, make sure you are not doing anything in the Initialize (IExtensionApplication) callback of your dll.
The following C# code illustrates how to write demand loading info into registry when run from the calling dll. You could eventually run it and see the result that it produces in the registry and also test if it can set up your dll for demand loading:
public void RegisterMe()
{
//AutoCAD (or vertical) and Application keys
Microsoft.Win32.RegistryKey acadKey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
HostApplicationServices.Current.MachineRegistryProductRootKey);
Microsoft.Win32.RegistryKey acadAppKey = acadKey.OpenSubKey("Applications", true);
string curAssemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
string curAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string curAssemblyFullName = System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName;
//already registered?
String[] subKeyNames = acadAppKey.GetSubKeyNames();
foreach (String subKeyName in subKeyNames)
{
if (subKeyName.Equals(curAssemblyName))
{
Microsoft.Win32.RegistryKey subkey = acadAppKey.OpenSubKey(subKeyName, true);
subkey.SetValue("LOADER", curAssemblyPath, Microsoft.Win32.RegistryValueKind.String);
subkey.Close();
acadAppKey.Close();
return;
}
}
//create the addin key
Microsoft.Win32.RegistryKey acadAppAddInKey = acadAppKey.CreateSubKey(curAssemblyName);
acadAppAddInKey.SetValue("DESCRIPTION", curAssemblyFullName, Microsoft.Win32.RegistryValueKind.String);
acadAppAddInKey.SetValue("LOADCTRLS", 14, Microsoft.Win32.RegistryValueKind.DWord);
acadAppAddInKey.SetValue("LOADER", curAssemblyPath, Microsoft.Win32.RegistryValueKind.String);
acadAppAddInKey.SetValue("MANAGED", 1, Microsoft.Win32.RegistryValueKind.DWord);
acadAppKey.Close();
}
I assume you are not trying to load from a remote/network location? there have been security features added since 2014, take a look there for further info:
http://adndevblog.typepad.com/autocad/2013/07/all-you-need-to-know-about-autocad-secureload-au.html
http://adndevblog.typepad.com/autocad/2013/03/autocad-2014-and-security.html
I hope it helps.
Regards,
Philippe.
Philippe Leefsma
Developer Technical Services
Autodesk Developer Network