sass / libsass-net

A lightweight wrapper around libsass
MIT License
94 stars 35 forks source link

w3wp.exe locks 'libsass*.dll' #55

Open janvanhelvoort opened 7 years ago

janvanhelvoort commented 7 years ago

Hi

After running the following code:

var compiler = new SassCompiler(new SassOptions { OutputStyle = SassOutputStyle.Compressed, InputPath = customScssPath });
var result = compiler.Compile();

The dll libsass* is locked, until we kill w3wp.exe

How can we release the resources?

With kind regards,

Jan van Helvoort

aviatrix commented 7 years ago

Hey Jan, What version of libsass are you running?

janvanhelvoort commented 7 years ago

Hi,

We use version 3.3.7 from libsassnet.

janvanhelvoort commented 7 years ago

Hi,

Can you reproduce the problem?

darrenkopp commented 7 years ago

I'm sure I could reproduce this problem if I tried as this happens with basically all native interop and I have encountered this issue before with the sql server binaries we use. I'm not sure if there's a real solution here though since there's no shadow copying of binaries for native interop. I'd have to do some research before I would know for sure.

janvanhelvoort commented 7 years ago

Hi,

Do you have a update?

aviatrix commented 7 years ago

can you please try updating to latest version and see if you can reproduce it ?

janvanhelvoort commented 7 years ago

yes, with 3.3.7-alpha-2 the files are locked within w3p.exe

aviatrix commented 7 years ago

The stable version should be the one to use, not the alpha, can you try that ? P.S. we are using alpha 2 in production with foundation 5.x (not the latest) as the scss compiler is not the latest.

janvanhelvoort commented 6 years ago

yes, every version of the package has the same problem.

wub commented 6 years ago

We're having the same problem; we had to inject a PowerShell script into our deployment process to get around it.

ChaosYoda commented 6 years ago

Is there a working solution for this? We are also using Azure and even on my Desktop it gets locked.

ghbla commented 5 years ago

You can do an exit hook in your application and unload the DLL on exit in the Global.asax.cs

    [DllImport("kernel32", SetLastError = true)]
    private static extern bool FreeLibrary(IntPtr hModule);
    public static void UnloadImportedDll(string moduleName)
    {
        var modules = System.Diagnostics.Process.GetCurrentProcess().Modules;
        foreach (System.Diagnostics.ProcessModule mod in modules)
        {
            if (mod.ModuleName == moduleName)
            {
                FreeLibrary(mod.BaseAddress);
            }
        }
    }

    void Application_End(object sender, EventArgs e)
    {
        UnloadImportedDll("libsass32.DLL");
    }