Feeds:
Posts
Comments

Archive for November, 2017

ASP.NET doesn’t make shadow copies of unmanaged DLLs such as libsodium.dll and libsodium-64.dll.

Sodium.dll (the managed code) tries to load the DLLs from either the same directory as the shadow copy of Sodium.dll (which is not going to work) – or some where in the PATH environment variable’s directories.

Solution 1:

add the AppDomain \Bin directory to the path before calling any Sodium code:

string
path = Environment.GetEnvironmentVariable("PATH");

string binDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “Bin”);
Environment.SetEnvironmentVariable(“PATH”, path + “;” + binDir);

Add the above code in Application_Start method of my Global.asax.

This solution works when u r running locally. but when you deploy in azure it wont work.

Solution 2:

You have to install Visual C++ Redistributable for Visual Studio 2015 (13 Mb)
https://www.microsoft.com/en-us/download/details.aspx?id=48145

I tried with this approach. but not completely successful.

Solution 3:

Add your bin folder path in environmental variables “path”. or Copy Sodium.dll  & libsodium-64.dll to your C:\Windows\System32 folder.

Solution 4:
Since we know that the binary is available on site root, we can either add site root path to PATH environment variable (binary in question along with all its dependencies are available under SiteRoot directory) or we can just disable Shadow Copying by adding following web.coinfg entry:

<system.web>
	<hostingEnvironment shadowCopyBinAssemblies="false"/>
</system.web>

AppDomain will now consider SiteRoot as it’s location and modifications to files under SiteRoot would cause application to crash and not a good idea on production environments. But since I always deploy a full CSPKG to production environment and never touch the files on production environment, I am good with this change.

Read Full Post »