Delphi 7 host, c# .net framework 4.7.2 plugin
Tried with both c# winforms and wpf. Same issue
Delphi 7 Host with existing Delphi 7 plugins works as expected and ModuleManager.UnloadModule works correctly.
Delphi 7 Host code is as follows
*// Get instance from ObjectList* *// After this call the VisualPluginIntf is populated correctly* VisualPluginIntf := i_PluginManager.Items[ItemIndex].IntfPointer; *// Call Release. No exception raised and after the call the VisualPluginIntf is nil as it is when called* *// For a D7 plugin* ModuleManager.ReleaseInstance(VisualPluginIntf); *// Unload module. Currently uses name, but we've also tried with index* ModuleManager.UnloadModule(i_PluginFileName);
At this point when unloading a .net plugin we receive exception
EHYException with message 'Plugin module WinformsPlugin.dll could not be unloaded, because the following plugin instances were not released Plugin "WinformsPlugin.Mainform" reference count : 1
Interestingly inspecting ModuleManager.fModules.Count before/after the call to ReleaseInstance shows the same number of modules - so Release must be failing even though we’re seeing the VisualPluginIntf of nil after the call.