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

Could not load file or assembly 'LibSassHost.Native-32' or one of its dependencies. An attempt was made to load a program with an incorrect format. #3

Closed
JonCubed opened this issue Jan 21, 2016 · 15 comments

Comments

@JonCubed
Copy link

It is working locally for me but when I try to run in on a remote server it fails with this stack trace. I have the visual c++ redistributable 2013 installed (x86 & x64) on the remote server, it looks to me like it is trying to use 32-bit version instead of 64-bit.

@Taritsyn
Copy link
Owner

Hello, Jonathan!

It seems, that the LibSass Host does not load one of the Visual C++ Redistributable 2013 assemblies.

How did you installed the Visual C++ Redistributable Packages for Visual Studio 2013: via installer or locally in bin directory?

@JonCubed
Copy link
Author

Via the installer.

I noticed that locally the LibSassHost.Native-32.dll and LibSassHost.Native-64.dll are in a subfolder in bin but on remote they are in the bin folder. When I replicate this structure I get a different error. The flattening of the structure seems to occur during msbuild publish when it uses the _CopyWebApplicationLegacy Target when publishing the website

[06:30:44][_CopyWebApplicationLegacy] Copy
[06:30:44][Copy] Copying file from "C:\TeamCity\buildAgent\work\f487e2bbb61aedc4\packages\LibSassHost.0.4.1\content\LibSassHost.Native\LibSassHost.Native-32.dll" to "..\Binaries\_PublishedWebsites\WebApp\bin\LibSassHost.Native-32.dll".
[06:30:44][Copy] Copying file from "C:\TeamCity\buildAgent\work\f487e2bbb61aedc4\packages\LibSassHost.0.4.1\content\LibSassHost.Native\LibSassHost.Native-64.dll" to "..\Binaries\_PublishedWebsites\WebApp\bin\LibSassHost.Native-64.dll".

Not sure if it really makes a difference or not

@JonCubed
Copy link
Author

@Taritsyn
Copy link
Owner

but on remote they are in the bin folder

This leads to error. You must restore the original folder structure.

Type 'System.Collections.Immutable.ImmutableStack`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' in Assembly 'NewRelic.Providers.CallStack.AsyncLocal, Version=5.12.13.0, Culture=neutral, PublicKeyToken=f7f92cc5c2dc8743' is not marked as serializable.

This error has no relation to my library.

@JonCubed
Copy link
Author

but on remote they are in the bin folder
This leads to error. You must restore the original folder structure.

fair enough

This error has no relation to my library.

If you continue down the stack trace there is an error with LibSassHost

[TypeInitializationException: The type initializer for '' threw an exception.]
LibSassHost.SassCompiler..ctor(IFileManager fileManager) +0
BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate(IList1 assets) +326 BundleTransformer.Core.Transformers.TransformerBase.Translate(IList1 assets, Boolean isDebugMode) +116
BundleTransformer.Core.Transformers.TransformerBase.Transform(IList1 assets, BundleContext bundleContext, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, Boolean isDebugMode) +106 BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse, Boolean isDebugMode) +347 System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles) +210

@Taritsyn
Copy link
Owner

I've seen that is on the bottom of stack. I just used wrong words, because all that is before line 31 is simply bewildering.

I think, that can close this issue, because it is a deployment error.

@starteleport
Copy link

@Taritsyn, I've got the same problem. Story is short: I've decided to update BundleTransformer from 1.9.34 to 1.9.89. After the update, I've started to get compilation errors (related to includes) on my scss files. After which, I've decided to update LibSassHost from 0.4.1 to 0.4.3. That's when I started to see this error message.

I can't believe this is deployment issue because it tries to load 32-bit dll into 64-bit w3wp.exe. Here is gist with fusion log (sorry, it's in Russian) and procmon dump that suggest that issue is with LibSassHost, and not with C++ Redistributable libs (it even does not try to read those).

Could you please help me figure out, what's going on?

@Taritsyn
Copy link
Owner

Taritsyn commented Mar 2, 2016

Hello, Nikolay!

Try to restart IIS, and then reinstall LibSassHost.

@starteleport
Copy link

@Taritsyn, I'm not sure what you mean by "reinstall LibSassHost", but I've tried many times, the most hard-core was to:

  • Stop IIS
  • Drop everything in site root directory
  • Drop everything in Temporary ASP.NET Files both in Framework and Framework64
  • Redeploy site
  • Repair installation of C++ Redistributable
  • Reboot
  • Start IIS

with no luck.

@Taritsyn
Copy link
Owner

Taritsyn commented Mar 2, 2016

Reinstall via NuGet.

@starteleport
Copy link

Finally figured it out. Started to work after I disabled Glimpse HTTP module. Very strange. Thanks, @Taritsyn!

@mynkow
Copy link

mynkow commented Oct 19, 2016

This error happens when you publish a website with MSBuild outside of VisualStudio. I am investigating if the nuget is built properly because these files are in Content folder.

@Section9Code
Copy link

Section9Code commented Mar 24, 2017

I was having exactly the same problem. Worked fine locally, but on the server wasn't working at all. Installed the latest C++ Redistributable then an IIS reset solved the problem.

@Taritsyn
Copy link
Owner

... then an IIS reset solved the problem.

@Section9Code During publishing of native assemblies, you must always reset IIS. I recommend you to read the “File lock on LibSassHost.Native-64.dll” discussion.

@Taritsyn
Copy link
Owner

Taritsyn commented Aug 9, 2019

Hello!

Since version 1.2.6 the MSVC runtime was embedded into the native assemblies for Windows. Now you do not need to install the Microsoft Visual C++ Redistributable.

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

5 participants