You can configure where Modlr plugins are loaded for MDriven Designer and the MDriven Visual Studio extension when you need to deploy or develop model-design-time extensions.
What this page covers
The modeling logic used by MDriven Designer and MDriven for Visual Studio has a plugin infrastructure. A plugin can extend the design-time environment; for example, it can add a context-menu operation, participate in code-generation events, add custom OCL operations, or expose information from the model.
This page explains how the plugin load folder is selected. For plugin interfaces, required assembly references, and implementation examples, see Documentation:Modlr plugin.
Default plugin folder
By default, MDriven loads plugin assemblies from:
%ProgramData%\MDriven\Plugins
The loader creates this directory if it does not already exist. Put the compiled plugin assembly in this folder, then restart MDriven Designer or the Visual Studio extension so that it loads the assembly.
For example, if %ProgramData% resolves to C:\ProgramData, the default folder is:
C:\ProgramData\MDriven\Plugins
Override the plugin folder
You can override the default folder for the current Windows user by creating a registry string value named PluginPath under:
HKEY_CURRENT_USER\Software\CapableObjects\Modlr
Set PluginPath to the full path of the folder that contains your plugin assemblies.
For example, set:
PluginPath = D:\MDrivenExtensions\Plugins
MDriven then creates and loads from D:\MDrivenExtensions\Plugins instead of the default folder.
Configuration steps
- Close MDriven Designer and Visual Studio.
- Create the folder that will hold the plugin assemblies, for example
D:\MDrivenExtensions\Plugins. - Open the Windows Registry Editor.
- Go to
HKEY_CURRENT_USER\Software\CapableObjects\Modlr. Create missing keys if required. - Create or edit the string value
PluginPath. - Enter the full folder path as its value.
- Start MDriven Designer or Visual Studio again.
The override is user-specific because it is read from HKEY_CURRENT_USER. A different Windows user must configure their own value if they also need the custom location.
How the location is selected
The loader uses the default location unless the PluginPath registry value exists:
private const string RegKeyName = @"Software\CapableObjects\Modlr";
public static void LoadPlugIns()
{
string path = Environment.GetFolderPath(
Environment.SpecialFolder.CommonApplicationData.LocalApplicationData);
path += @"\CapableObjects\MDriven\Plugins";
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegKeyName);
if (key != null)
{
path = key.GetValue("PluginPath", path) as string;
}
System.IO.Directory.CreateDirectory(path);
LoadPlugInAssemblies(path);
}
Choose the right extension approach
Use the extension type that matches what you need to do.
| Need | Use | Example |
|---|---|---|
| Add a menu operation, validate before code generation, or add a custom OCL operation | An assembly-based Modlr plugin | Add a command that is enabled only when the selected model element is a class. |
| Browse or export information held in the model's ExtendedModelLayer | A ViewModel-based plugin view | List every class with more than three attributes and export the result. |
| Extend a deployed Turnkey application | Turnkey components and plugins | Add application components to a Turnkey deployment. |
Read Documentation:Modlr plugin before building an assembly-based plugin. In current MDriven builds, design-time assemblies used by a plugin should be taken from the Visual Studio extension installation, not from NuGet packages.
For a ViewModel-based plugin view, open the plugin meta-model in MDriven Designer through File/Plugins/Open new meta-model for plugins. Create the ViewModel against the ExtendedModelLayer, save the plugin model in the plugin location, and reload plugins or restart the designer. You can then open the view from the model tree's Plugin Views menu. See Documentation:MDriven Designer and Modlr extensionsâexporting data for the full workflow and export example.
Reload and troubleshoot
After adding or replacing a plugin:
- Restart MDriven Designer or Visual Studio.
- If available in MDriven Designer, use the command to reload plugins from disk instead of restarting.
- Open a model and inspect the relevant context menu. Assembly-based menu operations appear where their enablement logic allows them; ViewModel plugins appear under Plugin Views.
If a plugin does not appear, check the following:
- Confirm that the assembly is in the selected folder, not a parent or nested folder.
- Confirm that
PluginPath, if configured, points to the intended folder. - Confirm that the plugin implements the interfaces described in Documentation:Modlr plugin.
- Confirm that the plugin was built against design-time assemblies from the Visual Studio extension installation when using newer MDriven builds.
- Restart or reload plugins after every deployment change.
Scope
This plugin infrastructure concerns model design time: MDriven Designer and the MDriven Visual Studio extension. It is separate from plugins used in Turnkey.
A Modlr file is a model-file format used by MDriven Designer and MDrivenServer. For team source control, use Ecomdl rather than a Modlr file because the zipped Modlr format does not diff well in Git or SVN.
