In our ASP.NET application, we have a function that allows you to use scripts in C # or VB.NET code. These scripts are stored in a database and compiled at specific intervals, executing the code that is stored in these scripts.
This works as long as the user writes the basic .NET code. Of course, our customers now request that they can reference their own DLLs to allow the execution of certain code. This is acceptable for us, and we are creating a solution for this. However, there is a specific scenario that we want to avoid at any time:
The application is not allowed to copy the associated DLL files to the BIN folder on the ASP.NET side, as this restarts the application and it is not supported / allowed
I played with the CompilerOptions class, and I noticed that you can install your libraries that you reference. From the information I could find on MSDN:
- You can set the library path using the following: CompilerOptions = "/ libpath: <path>" "
- You can add the link like this: CompilerOptions.ReferencedAssemblies.Add ("assembly name")
- You can add the link like this: CompilerOptions.ReferencedAssemblies.Add ("full assembly path")
In our scenarios, we also have the following mechanism; users can define the link area in their code, which contains the paths to the various user dlls needed to execute the script. An example script might look like this:
#region References /* * C:\Program Files\MailBee\MailBee.Net.dll * C:\Program Files\CustomApp\Custom.dll * System.IO.dll /* #endregion namespace custom.script.space { class CustomScript : Script { [EntryPoint] public voic run() { // do stuff } } }
This will link to the System.IO assembly and the two custom dlls specified. However, with the current implementation, we copied custom DLLs to the GAC, and then simply added their name as a reference to the compiler.
Is it possible to disable a copy of a DLL and use the full paths to these DLLs that can be referenced without copying them to the application’s GAC / bin folder? And is it possible to use CompilerOptions to install libpath, and let all links point to this?
The reason we don’t want to copy the Dll and restart the applications is because we have applications with multiple instances, several clients in one instance, and we cannot just restart the application.
I hope the question will be clear regarding what I'm trying to achieve ...