-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hello, in the web application with which I'm working we are using Libsass-net for compiling some .scss on runtime, substituting some colour variables in the process.
The weird thing is that locally everything seems to work fine (even if sometimes the error occurs), while when publishing on an azure web server, the compiling works just one or two times fine, after that the sassCompiler.Compile() starts to throw nullreferenceexceptions.
the error trace is the sequent:
System.NullReferenceException: at LibSass.Compiler.SassExterns64.sass_compile_file_context (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null) at LibSass.Compiler.Context.SassSafeFileContextHandle.CompileInternalContext (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null) at LibSass.Compiler.Context.SassSafeContextHandle.CompileContext (LibSass.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null)
while the code and the sobstitution that im using is the sequent:
private static CustomImportDelegate _customImportDelegate;
private SassImport[] SassImportDelegate(string currentImport, string parentImport, ISassOptions sassOptions)
{
var sassImport = new List<SassImport>();
var variablesImport = new SassImport();
if (currentImport.EndsWith("_variables_00_backend"))
{
variablesImport.Data = _colorString;
}
else
{
variablesImport.Path = currentImport;
}
sassImport.Add(variablesImport);
return sassImport.ToArray();
}
private string GenerateCss(string path)
{
_customImportDelegate = SassImportDelegate;
Telemetrytrace($"path is {path}");
var sassOptions = new SassOptions
{
InputPath = HttpContext.Current.Server.MapPath(path),
Importers = new[]{ _customImportDelegate },
IncludeSourceComments = false,
OutputStyle = SassOutputStyle.Compressed,
};
var sassCompiler = new SassCompiler(sassOptions);
var sassResult = sassCompiler.Compile();
return sassResult.Output;
}
Is there anyone that had the same problem? any solution out there?
thanks in advance! cheers.