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

Method not found: 'Void Microsoft.Extensions.Caching.Memory.MemoryCacheOptions.set_CompactOnMemoryPressure(Boolean)'. #69

Closed
503503503 opened this issue May 26, 2017 · 8 comments

Comments

@503503503
Copy link

I have created a class to get the static page after use RazorLight.

The code is:

public class RazorLightHelper : IRazorLightHelper where T : class, new()
{

    public string GetStaticPage(string templateUrl, string templateFileName, T t)
    {
        try
        {
            // Instance the Model
            var entity = new T();
                                            
            var engine = EngineFactory.CreatePhysical(@"F:\TFS Task\qin.job\src\Qin.JobManager\Template");
            
            string result = engine.Parse(templateFileName, entity);
                            
            return result;
        }
        catch (Exception e)
        {
            throw e;
        }
    }
}

But there is a bug happened for CreatePhysical. And Error message is Method not found: 'Void Microsoft.Extensions.Caching.Memory.MemoryCacheOptions.set_CompactOnMemoryPressure(Boolean)'.

I have no idea the reason and how to resolve it.

@toddams
Copy link
Owner

toddams commented May 26, 2017

Tell me more about the environment you are running:
Platform,
OS,
Is it full .net or core,
What version of .net sdk and CLI tools (in case of core)

@sejrsgaard
Copy link

I just wanted to chime in on this as I have experienced the same exception in my environment.

Details:
Windows 10
Visual Studio 2017 15.3 Preview
.NET Command Line Tools (2.0.0-preview1-005977)
.NET Core 2.0.0-preview1-final

It happened while I was using FluentEmail which has a razor renderer that utilizes RazorLight. The culprit is the following section:

var engine = EngineFactory.CreatePhysical("/");
return engine.ParseString(template, model);

@toddams
Copy link
Owner

toddams commented May 30, 2017

It's already reported that RazorLight does not work at .NET Core 2.0

We are waiting till stable release.

@darkengines
Copy link

According to aspnet/Caching#320, CompactOnMemoryPressure is now back and marked as depreciated on the nigthly version of Microsoft.Extensions.Caching.Memory which may make RazorLight usable in appnetcore2.0.

If you are directly using the CompactOnMemoryPressure property, you should remove/replace any reference to it.

@dam3210
Copy link

dam3210 commented Mar 25, 2020

Hi,
I have this error at .Net core 3.1. Does this mean .net core 3.1 is (now) not supported?
Btw great library!

@jzabroski
Copy link
Collaborator

@dam3210 You can debug this yourself by opening RazorTemplateCompiler and in the file view in Visual Studio, selecting RazorLight (netcoreapp3.0) and on line 43, new MemoryCacheOptions(), right click on the text MemoryCacheOptions and go to View Definition. You can see the class decompiled contains no references to CompactOnMemoryPressure.

So, I have no idea how you are claiming you have this error. Please open a new ticket with your stack trace and details, like your csproj set-up. Please don't assume a 2 year old issue is the same one you're having. If you think it's the case, mention it at the bottom of the new issue. We don't call CompactOnMemoryPressure anywhere in the solution, so if you want good service, please give better feedback on what's not working.

@dam3210
Copy link

dam3210 commented Mar 25, 2020

@jzabroski thnx for your support. After a while, i noticed something weird with other libraries i downloaded. So start looking into that. Apparently something went wrong with Nuget Package Manger and had nothing to do with your library. Sorry to bother you, but thanks for you help :)

@jzabroski
Copy link
Collaborator

No worries. Happy bug hunting.

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

6 participants