sass / libsass-net

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

The type initializer threw an exception #45

Closed briceo closed 7 years ago

briceo commented 7 years ago

In trying to use the alpha version of libsassnet (3.3.7-alpha-2), I am able to run the SASS compiler locally on my dev machine, but trying to execute it on the deployment server produces the following error:

The type initializer for 'LibSass.Compiler.SassCompiler' threw an exception.

I have installed the VC2013 x64 Runtime, and I even tried installing the VC2015 x64 Runtime. I'm assuming it is just some dependency that I missed installing, but I'm not seeing what it was. Any help would be appreciated! Thanks!

darrenkopp commented 7 years ago

What type of application is it? You are sure it's running as a 64-bit application? Also, verify that libsass64.dll is in the bin directory

briceo commented 7 years ago

It is a WCF library, and it is running as 64-bit. It turns out that my build infrastructure had some issues and it produced some garbage that led to this. Thanks for the quick response. I'll close this issue.

briceo commented 7 years ago

So this happened again on a different server, and I don't think it is my build infrastructure this time: System.TypeInitializationException: The type initializer for 'LibSass.Compiler.SassCompiler' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libsass64': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I verified that the libsass64.dll DLL is in the same directory as my main executable that is ultimately calling out to the libsass libraries.

briceo commented 7 years ago

It appears that the VC2015 runtime is dependent on the Universal C Runtime, and if that isn't there then of course the sass library won't load. The funny thing is, I had the VC2015 Runtime installed (somehow), but I didn't have the Universal C Runtime installed.

I'm working to get that installed now, and I'll update this ticket once I test that scenario, just in case somebody else runs into this issue later on.

aviatrix commented 7 years ago

That's very weird, we had blank VMs from azure and just had to install VC2013/15 and it just worked. Is there something unusual about your environment? For example are you running Windows Server Core?

briceo commented 7 years ago

I was not running Windows Server Core. It turns out that the server had not had Windows Updates installed that introduced the dependency of Universal C Runtime, and the VC2015 Runtime _mostly_ installed (it actually failed at the very end, but finished enough that it put the runtime DLLs in the right spots).

I had used dependency walker to trace the actual DLLs that needed to be there, and that's how I found what was missing.

Once I installed the missing Windows Updates (roughly 1Gb worth of downloads) it worked as expected.

aviatrix commented 7 years ago

thank you for the replay! This should be enough info if someone else encounters the issue :)