What does Util.NewProcess do underneath in LINQPad 6 (dotnet Core)?
I have a script that does some type casting like this in Linqpad6 running under .NET Core 3.1 to replicate an issue we have in production:
var p = (IAuditedEventModel)empRecDesrializedToObject;
First time I execute, it works fine but if I make changes to the script (e.g. adding a comment) and re-run I get this InvalidCastException:
Unable to cast object of type 'EmployeeRecordTypeChanged' to type 'IAuditedEventModel'.
I also noticed that after making change and re-running the script, some Assemblies, like the ones for LinqPad6Query are loaded multiple times.
If I add a Util.NewProcess = true; at the beginning, things work fine even after making changes to the script.
Since we are getting the same exception in an Azure Function in production I'd like to know what that NewProcess = true flag is doing? Is it creating a new AppDomain every time the script runs?