1

I need to use the C# dll from C++ code. Is there any way to use the dll without register it into registry. Because register in registry needs administrative privilege. If any suggestion please let me know

Hari E
  • 526
  • 2
  • 14
  • 1
    It is called "Registration-free COM" and it is 100% can be done for C++ com dll, but I'm unsure if it's possible for .net com dll. Anyway, you can refer here https://learn.microsoft.com/en-us/dotnet/framework/interop/configure-net-framework-based-com-components-for-reg for some on-topic details. – Serg Oct 18 '22 at 05:27
  • 1
    COM components (including .NET ones) can be registered in HKCU instead of HKLM. Although regasm doesn't support it, you can do it yourself as explained here: https://stackoverflow.com/a/35789844/403671 That being said, reg free COM works fine for .NET and .NET Core/5/6+. – Simon Mourier Oct 18 '22 at 06:14
  • I tried to register in HKCU manually but it doesn't work. I need to register through C++ application. Here https://stackoverflow.com/a/12422441/19616470 he mentioned that CoCreateInstance() only look at HKEY_CLASSES_ROOT Hive – Hari E Oct 18 '22 at 10:03
  • 1
    The text in the link is plain wrong (and it's mentioned in various comments on this question), CoCreateInstance looks for HKCU first. I use that every day. If it doesn't work in your case, it's for some other reason. You can check with a tool such as Process Monitor from sys internals https://learn.microsoft.com/en-us/sysinternals/downloads/procmon and filter by process/registry access. The register code for C++ is the same it can be ported easily from C# to C++. – Simon Mourier Oct 18 '22 at 10:08
  • Thanks. I will try to figure out the problem through Process Monitor – Hari E Oct 18 '22 at 10:10

1 Answers1

0

I solved this Problem by Register the COM dll in HKEY_CURRENT_USERS hive by this code https://stackoverflow.com/a/35789844/19616470

Hari E
  • 526
  • 2
  • 14