How can I run a child script within the AppDomain of the parent script?

Util.Run/Compile executes child .linq script in a separate app domain and communicates results via serialization/deserialization.

How would you run a child script in the same app domain of the parent script?

The reason I want to do this is that I want to create an instance of a type that I did not write from the child script to the parent script. The type is not [Serializable] nor MarshalByRefObject.

Do I need to take care of compilation/run myself or does Linqpad have something I'm missing?

If not, this would be a very cool feature: something with the simplicity of Util.Run, but running in the parent app domain.

Thanks!

Comments

  • I'm considering allowing this in the future. However, there are some tradeoffs, such as not being able to unload the query assembly, or any of the assemblies it references, and not being able to safely cancel the query.
  • That's great that you are considering that feature! I came up with a solution in the meantime: https://gist.github.com/ronnieoverby/57c649eca6039985d242f575a2c1d22c

    This need arose while I was making some changes to the Raven DB Linqpad driver. The root object instance used to access Raven DB (IDocumentStore) has some configuration that is set by supplying delegates, which doesn't lend itself well to being configured by a WPF / WinForms dialog.

    Before, I allowed the users of the driver to supply an assembly path that is expected to contain an implementation of a well-known interface that can create the IDocumentStore instance that meets their needs.

    My goal is to allow the users of my driver to instead supply a .linq file in the connection configuration that will create the instance. This could be much more convenient for many users of the driver.

    If you have any comments on either the code @ the gist link or the approach I've explained for the driver, I'd love to hear your thoughts.

    Thanks again!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!