public static void Register( string InDescription, params string InUserAssemblies )
Public Shared Sub Register ( InDescription As String, ParamArray InUserAssemblies As String() )
public: static void Register( String^ InDescription, ... array<String^>^ InUserAssemblies )
static member Register : InDescription : string * InUserAssemblies : string -> unit
|FileNotFoundException||At least one of the files specified could not be found!|
|BadImageFormatException||Unable to load at least one of the given files for reflection.|
|ArgumentException||At least one of the given files does not have a strong name.|
ATTENTION: There are some problems when debugging processes whose libraries are added to the GAC. Visual Studio won't start the debug session! There is only one chance for you to workaround this issue if you want to install libraries AND debug them simultanously. This is simply to debug only one process which is the default setting of Visual Studio. Because the libraries are added to the GAC AFTER Visual Studio has initialized the debug session, there won't be any conflicts; at least so far...
In debug versions of EasyHook, you may also check the "Application" event log, which holds additional information about the GAC registration, after calling this method. In general this method works transactionally. This means if something goes wrong, the GAC state of all related libraries won't be violated!
The problem with NET assemblies is that the CLR only searches the GAC and directories starting with the application base directory for assemblies. To get injected assemblies working either all of them have to be located under the target base directory (which is not suitable in most cases) or reside in the GAC.
EasyHook provides a way to automatically register all of its own assemblies and custom ones temporarily in the GAC. It also ensures that all of these assemblies are removed if the installing process exists. So you don't need to care about and may write applications according to the XCOPY standard. If your application ships with an installer, you may statically install all of your assemblies and the ones of EasyHook into the GAC. In this case just don't call Register(String, String).
Of course EasyHook does also take care of multiple processes using the same injection libraries. So if two processes are sharing some of those DLLs, a stable reference counter ensures that the libraries are kept in the GAC if one process is terminated while the other continues running and so continues holding a proper GAC reference.
Please note that in order to add your library to the GAC, it has to be a valid NET assembly and expose a so called "Strong Name". Assemblies without a strong name will be rejected by this method!