Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sybaris opened this issue Jun 3, 2023 · 6 comments
Open

Comments

@sybaris
Copy link

sybaris commented Jun 3, 2023

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

@GaryWayneSmith
Copy link

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.

@sybaris
Copy link
Author

sybaris commented Sep 1, 2023

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...

@mshakurov
Copy link

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?

@GaryWayneSmith
Copy link

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.

@mshakurov
Copy link

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.

@mshakurov
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants