Question

I am trying to write a program in c#. Part of it needs to be be able to detect if a file(mostly dlls, but some other aswell) is registered. And the user must then be able to select a file(or files) that he/she wants to register and the program must register it. It shouldnt just register all the files, the user must decide which to register

So mainly I am wonder how to detect if its registered, and how to register it

Thank you in advance for your help

EDIT: OK, so how do you detect if a .net assembly is registered from within a C# program?

Was it helpful?

Solution

You should define what does it mean "to be registered". Standard DLL files are NOT registered anywhere. (That's why can see chaos called "DLL Hell".)

Or is it COM?

COM components are registered using regsvr32.exe. You can call it to register your files. This is the simplest way. If you for some reason think you don't want this simple way, you can do it manually - read COM documentation on information how the component can register itself. (You load the file into your address space and let it register itself by calling the registering function in it.)

I don't know how to legally detect if a particular file is registered as a COM component host if you don't know what component is inside. But if you know the component, you can try to create the component. If the creation fails, the file is not registered yet.

Or are they .NET assembly files?

In .NET you are not allowed to "register" files at your will, you need administrator rights. (The process must run in elevated mode.) But again, you normally use these .NET DLL files without registration. Normally only well trusted core system components are registered in GAC. I think it can be a security hole if you try to add your private files into GAC. So I would ask if it is relly so important to have them registered there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top