A workaround for calling regasm without the admin rights was described here already:
COM Interop without regasm
I\'m trying to create a COM library that my u
Calling regasm without administrative rights for COM interop
I think it should be possible to use RegistrationServices.RegisterAssembly and RegOverridePredefKey APIs together to implement automatic registration under the HKCU
hive, in a UAC-friendly way. I've posted a more detailed answer here.
Yeah, now you have two problems, you cannot put it anywhere you should put it, like the GAC or a c:\program files subdirectory. Since those locations also require UAC elevation. You probably also forgot to run Regasm.exe with the /codebase option, required to tell the CLR where to look for the file.
The user needs to have enough privileges to copy the DLL to a directory he has write access to. That's normally only a directory in c:\users\username, like the appdata subdirectory. The headache you'll have to address that the .reg file needs to be adapted for each individual user since his username is different. So the CodeBase
value in the .reg file needs to be changed for each user. This scales poorly, to put it mildly.
The answer you found is just not a very good one. The only solution that really works is to write your own registration function. One that writes the registry keys in HKCU instead of HKLM. Use the [ComRegisterFunction] attribute. You know from the .reg file what keys you need to write. And you use Assembly.GetExecutingAssembly().Location to figure out what to write for CodeBase registry value. Don't forget the [ComUnregisterFunction].
Do keep in mind that, at least in spirit, you are trying to sail around the restrictions that the LAN admin imposed on these users. They do care a lot about knowing what kind of code runs on the machines they support. This may well get you in trouble, at least talk to the guy.