Possible to register NET 6 plugin as normal user?

Hello,

I have been pleasantly surprised that according to WPF Visual Plugins (.NET 5+) Hydra allows to build .NET core / 5+ plugins.
However the last entry indicates that I need to run regsvr32 .\PluginSample_WinForms.comhost.dll in order to register the plugin.
My application relies on xcopy deployment and doesn’t need escalated privileges. Is it possible to register the plugin at runtime in a non elevated context?

Thank you

Good question. i’m afraid i’ll have to leave this for my colleague to answer, early next week. I agree that ideally this shuold be possible.

Hello

By default escalated privileges are required to register COM component related to your plugin.

Theoretically you could take a look at this topic to register COM component without admin rights:

It is possible to check and modify registry at runtime.

However please note that this approach is not officially supported, so I suggest you to retest your application after the changes.

Hope that helps

Thank you.
I wanted to try the approach outlined on stackoverflow, but I have failed in getting a simple example (Delphi Host, NET 6 WPF plugin) to run (even as admin).
Could you please provide me with an example for this ( I could not find any project that targets this scenario in the examples folder)?

Thank you

1 Like

Hello

This approach is not officially supported. So there is no samples for it.

This approach works for COM-based .NET Framework plugins.
However if fails for new .NET COM components (apparently its registration code does more than just writing registry issues).

Seems the only solution would be to override registry path and then run the component registration procedure (again, it is NOT officially supported):

  // not a real code !!!
LoadLibrary("Oleaut32.dll")
    GetProcAddress("OaEnablePerUserTLibRegistration")
    Marshal.GetDelegateForFunctionPointer()
    Call OaEnablePerUserTLibRegistration()

    key = RegOpenKey(RegistryHive.CurrentUser, @"Software\Classes")
        RegOverridePredefKey(RegistryHive.ClassesRoot, key)
    RegCloseKey(key)

        LoadLibrary("YourLibrary.comhost.dll")
            GetProcAddress("DllRegisterServer")
            Marshal.GetDelegateForFunctionPointer()
            Call DllRegisterServer()
        FreeLibrary()

    RegOverridePredefKey(RegistryHive.ClassesRoot, null)
FreeLibrary()

Thank you for your suggestion, we made it work using registration-free activation as described here: How to: Configure .NET Framework-Based COM Components for Registration-Free Activation - .NET Framework | Microsoft Docs

A quick summary can be found here:

This approach does not require any hacks, prior external registration or elevated privileges, all configuration is done in a custom manifest.
If you think this is something that could provide value to other users of hydra, I can upload a working sample project (Delphi host, NET 6 wpf plugin)

1 Like

Hello

Yes, a sample app would be great.

Logged as bugs://H1022.

My apologies, I have been incapacitated for a bit. You will find a working example here: Storage Share
I managed to get it running using the approach above in x86, but did not manage in x64