Antaris/RazorEngine

'AppDomainSetup' does not contain a constructor that takes 0 arguments

sybaris opened this issue · 6 comments

Hi,

I am using .NET 6.0 and RazorEngine.NetCore.

From documentation, I copy/paste the following snippet of code :

            if (AppDomain.CurrentDomain.IsDefaultAppDomain())
            {
                // RazorEngine cannot clean up from the default appdomain...
                Console.WriteLine("Switching to secound AppDomain, for RazorEngine...");
                AppDomainSetup adSetup = new AppDomainSetup();
                adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                var current = AppDomain.CurrentDomain;
                // You only need to add strongnames when your appdomain is not a full trust environment.
                var strongNames = new StrongName[0];

                var domain = AppDomain.CreateDomain(
                    "MyMainDomain", null,
                    current.SetupInformation, new PermissionSet(PermissionState.Unrestricted),
                    strongNames);
                var exitCode = domain.ExecuteAssembly(Assembly.GetExecutingAssembly().Location);
                // RazorEngine will cleanup. 
                AppDomain.Unload(domain);
                return exitCode;
            }

And I have a build error : 'AppDomainSetup' does not contain a constructor that takes 0 arguments.
What is the solution ? Is it possible to fix also the documentation please ?

Regards
Sybaris

This codebase hasn't been updated in a while and feels pretty abandoned. I'm using this in .Net Framework 4.6 and I'm starting to migrate a lot of stuff to Net 6. This is one of the lingering things I have to replace as we use this for a lot of email generation. If you find a working solution to getting this fully operation in Net 6, please let us know.

Thanks for answering me.
For information, I abandoned this project, and instead I use RazorLight which is more responsive in terms of answering questions, and the code seems more stable...

Is someone finally going to answer this question? Why is there one thing in the documentation, but another in reality? Have Microsoft developers forgotten a whole stack of technologies?

Is someone finally going to answer this question? Why is there one thing in the documentation, but another in reality? Have Microsoft developers forgotten a whole stack of technologies?

This is pretty much a dead project. I have been searching for viable alternatives for some time as I transition over to a new code base.

Is someone finally going to answer this question? Why is there one thing in the documentation, but another in reality? Have Microsoft developers forgotten a whole stack of technologies?

This is pretty much a dead project. I have been searching for viable alternatives for some time as I transition over to a new code base.

I mean..
Is there a way to load an assembly, examine its types, and unload the assembly and its types?
How to deal with similar tasks from the Net Framework now, in which it is necessary to download, examine and further unload assemblies, so that neither those assemblies nor their types remain in memory.

I understand that you can use the launch of a separate application in which to do the work, get the necessary information, and hang that application. But to do this, you need to write a bunch of code, whereas AppDomain had convenient methods like CreateInstanceAndUnwrap.