Skip to content

Avoid locking plugin DLLs when loading #5

Description

@dylanrenwick

Is your feature request related to a problem? Please describe.
When developing plugins, DesktopMagic needs to be fully closed to overwrite a plugin. This results in a frustrating loop of Make Change -> Close DM -> Update plugin file -> Reopen DM -> Repeat
Currently DesktopMagic uses Assembly.LoadFrom to load plugin DLLs. This results in a file lock on the plugin's main.dll, which prevents hot updates.

Describe the solution you'd like
A possible solution seems to be shadow copying, which copies the target DLL to a temp directory and loads the copy, but still uses the original path for binding context. This would allow DesktopMagic to load plugin assemblies without locking the original file, allowing the plugin to be hot-updated by overwriting the file and hitting "Reload" in DM.
A caveat to this is that the article linked in the above SO thread only applies to .NET Framework, and I'm struggling to find resources on shadow copying in general assembly loading on .NET 8+

Describe alternatives you've considered
It seems shadow copying could be implemented manually, though that could have unforeseen issues and inflates the scope of the change. I've also seen mention of 3rd party frameworks/libraries that can accomplish generic dotnet assembly "plugin" loading with hot reload support, such as MEF (Managed Extensibility Framework).
MEF is specific to .NET Framework 4, but modern alternatives may be available.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions