I have an old webservice build on ASP.NET (using .asmx) files. I need to use sodium.net - unfortunately it fails while loading the dependent libsodium.dll file. Any ideas about what I make wrong?
I have added libsodium.net through NuGet.
I have renamed the 64 bit DLL to "libsodium.dll" (and other naming conventions too).
I have tried to reference libsodium.dll directly but VS rejects it (not a valid DLL). So I have added it as "content" instead with "copy to output".
After building I can see that the website/Bin folder contains both sodium.dll (the .NET assembly) and libsodium.net.
When I try to use libsodium.net I get:
ERROR 2015-02-02 11:14:27,118 13798ms [41] CabinetService doRequest - Caught: The type initializer for 'Sodium.SodiumCore' threw an exception.
System.TypeInitializationException: The type initializer for 'Sodium.SodiumCore' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libsodium.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at DynamicDllInvokeType.sodium_init()
at Sodium.SodiumCore..cctor()
--- End of inner exception stack trace ---
at Sodium.SodiumCore.LibraryName()
at Sodium.SecretBox.Create(Byte[] message, Byte[] nonce, Byte[] key)
at Macaroons.SecretBoxCryptoAlgorithm.Encrypt(Byte[] key, Byte[] plainText) in c:\Projects\Macaroons.Net\Macaroons.Net\SecretBoxCryptoAlgorithm.cs:line 58
So it cannot find "libsodium.dll" even though it is in the Bin folder. I did also try to remove the dependency on "sodium.net" where after I got a runtime error saying "sodium.net" is missing - when I re-added it, that error disappeared and I got the one above instead (indicating the "sodium.net" loads correctly).
So I open up the website shadow folder in "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\cabinetservice" and search for "sodium". The only result is "sodium.dll" in some subfolder. There is no "libsodium.dll".
So apparently ASP.NET ignores the "libsodium.dll" file when creating the shadow copy of the website.
I have also tried adding the libsodium.dll (32 bit) to C:\Windows\System32 and libsodium.dll (64 bit) to C:\Windows\SysWOW64. Same result.
And I have tried C:\Windows\Microsoft.NET\assembly\GAC_32\libsodium and C:\Windows\Microsoft.NET\assembly\GAC_64\libsodium. Same result.
How can I make ASP.NET aware of the dependency?
It turns out that 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.
My solution was to add the AppDomain \Bin directory to the path before calling any Sodium code:
// Make it possible to load unmanaged libsodium DLLs that .NET does not make shadow copies of.
// -> Simply point the "path" variable to the Bin directory.
string path = Environment.GetEnvironmentVariable("PATH");
string binDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Bin");
Environment.SetEnvironmentVariable("PATH", path + ";" + binDir);
Update January 2018 (from Jordan Rieger's answer):
Note that you may also need to install the Microsoft Visual C++ 2015
Redistributable on your server (either the x64 or x86 target,
depending on your process.)
Don't forget to restart your app pool (I did an IIS reset) after
installing the redistributable.
Note that you may also need to install the Microsoft Visual C++ 2015 Redistributable on your server (either the x64 or x86 target, depending on your process.)
Don't forget to restart your app pool (I did an IIS reset) after installing the redistributable.
See my comment on https://stackoverflow.com/a/45078280/284704.
Related
I have a problem only on a specific machine.
I have two programs with a reference to Sap.Data.Hana.v4.5.dll, the ADO.NET Provider for .NET 4.5 for HANA database.
When my programs instantiates a connection object with
dbConnection = new HanaConnection(...);
I get this error:
System.TypeInitializationException: The type initializer for 'Sap.Data.Hana.HanaConnection' threw an exception. ---> System.IO.FileNotFoundException: Cannot find libADONETHDB.dll.
at Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls(String regKeyName)
at Sap.Data.Hana.HanaUnmanagedDll..ctor()
at Sap.Data.Hana.HanaUnmanagedDll.get_Instance()
at Sap.Data.Hana.HanaConnection..cctor()
--- End of inner exception stack trace ---
at [...my program calls...]
Why can't it find libADONETHDB.dll?
My applications are build one in 32-bit, the other in 64-bit.
On this machine I installed SAP HANA client 2.8.20.23662 (latest version) both 32-bit and 64-bit.
The file that cannot be found seems to exist:
You could use Process Monitor while running the relevant part of the program to see, which file is missing and the path it should be in. Exclude all other events than file events and filter out all SUCCESS messages.
Perhaps it is referenced relative to the calling DLL (where Sap.Data.Hana.HanaUnmanagedDll.SearchNativeDlls is defined).
My hipotesis is that GAC had been corrupted with version 1 of Sap.Data.Hana.v4.5.dll:
Probably in the past HANA Client version 1 had been installed and removed and uninstallation hadn't cleaned the GAC.
My program uses HANA Client of any version, works both with version 1 and 2. For some reason when they start they seem to take version 1 of Sap.Data.Hana.v4.5.dll in the GAC. Process Monitor (thanks #sc911) confirms it:
This .NET DLL then looks for some unmanaged DLLs in C:\Program Files (x86)\hdbclient. Version 1 seems to look for libADONETHDB.dll in root folder.
But currently in this machine in that folder we have HANA Client 2.x and its folder structure is quite different from that of version 1 (there is no libADONETHDB.dll in root folder).
Hence the error in this question.
All this is valid both for 32-bit and 64-bit HANA Client.
I solved renaming or deleting version 1 folder in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Sap.Data.Hana.v4.5 (probably there are better ways for performing this cleanup).
Every time i try to compile i'm getting this error:
System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)'
when i try to run session = PXCMSession.CreateInstance();
I'm running Windows 10 pro, 32 bit operating system.
Added reference to file:
c:\Program Files\Intel\RSSDK\bin\win32\libpxcclr.cs.dll
added to post build evenent:
if "$(Platform)" == "x86" ( copy /y "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "$(TargetDir)" ) else ( copy /y "$(RSSDK_DIR)\bin\x64\libpxccpp2c.dll" "$(TargetDir)" )
And in build tab changed platform target from Any CPU to X86
That exception is usually, in my experience, due to a x64/x86 conflict. Are you definitely referencing the x86 version of libpxcclr.cs.dll?
The fix is to go back to cmake and build with the x64 compilers on your system. If you don't see the prompt for the compiler version, delete the "build" directory and try cmake-gui again. All the C# examples work in x64 but don't in 32-bit.
I was about to update my existing windows 8.1 universal app to VS2015 along with its portable projects.But it fails with below error
"Error : DEP6810 : MdilXapCompile.exe failed with error code 1004. See log file 'C:\xxx\xxx.WindowsPhone\obj\ARM\Debug\MDIL\MDILXapCompileLog.txt' for more details"
The Log file Contents
Error: Compile filter argument specified non-existent file: C:\xxx\xxx\xxx.WindowsPhone\obj\ARM\Debug\MSIL\PhoneLibrary\Microsoft.SharePoint.Client.Portable.dll
Invalid argument
Microsoft (R) MDIL XAP Compiler - Version 4.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: MDILXAPCompile /In:<InputPath> /Out:<OutputPath> /Config:<ConfigPath> [/CompileFilter:<Assembly Path>;<Assembly Path>] [/Timeout:<Timeout>] [/Log:<LogPath>] [/AppX]
/In - Path to directory containing files to process
/Out - Path to directory to place processed files in
/Config - Path to configuration file
/CompileFilter - Optional restrictive list of assembly files in InputPath,
separated by semi-colons, to be compiled.
/Timeout - Optional timeout in milliseconds before killing the Crossgen process. Overrides config file timeout value. Use -1 for infinite timeout, 0 for application default (2 hours).
/Log - Optional path to log file
/AppX - Specifies that assemblies correspond to an AppX package
Relative paths are relative to this executable's directory.
I get this error only when I debug the project but it works normal when i generate package and deploy it to device.
Answers are highly appreciated.
I got this solved. But may not be the direct way. Its quite strange.
I referred my dll's from the folder(named as PhoneLibrary) inside the app. As per log file location "C:\xxx\xxx\xxx.WindowsPhone\obj\ARM\Debug\MSIL\PhoneLibrary\Microsoft.SharePoint.Client.Portable.dll" it failed to create the folder.
So i just created folder in that location and copied my dll's in that folder and worked great.
I've added a reference to the CUDAfy.NET library via NuGet.
<package id="CUDAfy.NET" version="1.12.4695.21111" targetFramework="net45" />
When I run my program, I hit a Win32Exception:
The system cannot find the file specified
This happens on the first actual line of the program:
CudafyModule km = CudafyTranslator.Cudafy();
There's no indication from the exception object as to what file they're attempting to load.
How can I get past this problem?
EDIT
I see the same exception when running the bundled examples from the Codeplex download in VS2010 using .NET 4.0.
The strack trace is:
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at Cudafy.CudafyModule.Compile(eGPUCompiler mode, Boolean deleteGeneratedCode)
at Cudafy.Translator.CudafyTranslator.Cudafy(ePlatform platform, eArchitecture arch, Version cudaVersion, Boolean compile, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(ePlatform platform, eArchitecture arch, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy()
Setting VS to break on thrown exceptions shows the ProcessStartInfo object at the top of the stack in the locals pane of the debugger.
The relevant properties are:
FileName = nvcc
Arguments = -m64 -arch=sm_12 "c:\<path>\CUDAFYSOURCETEMP.cu" -o "c:\<path>\CUDAFYSOURCETEMP.ptx" --ptx
Some information from this article explains that the CUDA Toolkit must be installed. Fair enough.
Ensure that the C++ compiler (cl.exe) is on the search path. This set-up of NVCC is actually the toughest stage of the whole process, so please persevere. Read any errors you get carefully - most likely they are related to not finding cl.exe or not having either 32-bit or 64-bit CUDA Toolkit.
That article discusses version 4 of the toolkit, but version 5 is available now and supported since CUDAfy v1.1.
Download from https://developer.nvidia.com/cuda-downloads
Note that the 64-bit version of the CUDA Toolkit 5.0 is a 942 MB download. If you install everything you'll need an additional 2815 MB. The toolkit alone requires 928 MB.
EDIT After installing the CUDA Toolkit 5.0, the program failed with a CudafyCompileException at the same source line:
Compilation error: nvcc : fatal error : Cannot find compiler 'cl.exe' in PATH
Searching my system drive:
C:\>dir /s cl.exe
This shows many different versions of the compiler/linker, both from VS 10.0 and 11.0. Apparently only cl.exe versions 9 and 10 are supported, so I opted for the VS10.0 amd64 version, I included the following in my PATH environment variable:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
Your path may be different, depending upon your CPU. I recommend running the search to see your options.
Note that you will have to restart VS after changing the PATH environment variable if you already have it open.
After taking these steps, my basic program ran successfully.
This may also happen if you had at some point installed CUDA Toolkit v7.5, but realized that the most recent version of CUDAfy supports CUDA 7.0.
On uninstalling CUDA 7.5 from the control panel, some files/folders may still remain. You should delete these manually. You may use CUDAfyViewer to see which version of CUDA Toolkit is being accessed.
Note: This section contains incorrect information - skip to the update below for details. This section left in for historical purposes.
I have a WPF project in Visual Studio 2008 targeting .NET 3.5 that references SharpSVN. When I make a call into SvnClient.Export, I get an exception that Marshal.GetExceptionCode tells me is 0xc06d007e. This seems to be caused by a bad DLL. I have tracked (with the Dependency Walker) that DLL to two culprits: IEFRAME.DLL and SHLWAPI.DLL. They are missing the following export functions:
SHLWAPI.DLL: #270
IEFRAME.DLL: #141, #159, #160
I also initially had a missing DLL that was fixed by adding %ProgramFiles%\Internet Explorer to the path. I do not recall the DLL name.
This is a fresh install of Visual Studio 2008, SharpSVN 1.7002.1998.12257.
I can run the "svn" command that is provided with SharpSVN to export from our repository, so I am leaning toward a solution/project configuration/reference problem.
How do I fix this error?
*Update: I have refined my understanding of this problem. The SHLWAPI and IEFRAME issues appear to be a normal condition - User32.dll has the same behavior. I modified my environment in the following ways:
Environment variable [SVN_SSH] set to TortoisePlink [C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe]
Updated uri target to use current username:
SvnUriTarget uriTarget =
new SvnUriTarget("svn+ssh://" + Environment.UserName + "#myserver/mypath");
With this configuration, I can successfully export when running this code as part of the WPF application. However, I still get errors when running as part of a MSTest project.
System.Runtime.InteropServices.SEHException: External component has thrown an exception.\r\n
at svn_client_export5(Int32* , SByte* , SByte* , svn_opt_revision_t* , svn_opt_revision_t* , Int32 , Int32 , Int32 , svn_depth_t , SByte* , svn_client_ctx_t* , apr_pool_t* )\r\n
at SharpSvn.SvnClient.Export(SvnTarget from, String toPath, SvnExportArgs args, SvnUpdateResult& result) in g:\\dist\\src\\sharpsvn\\commands\\export.cpp:line 100
at SharpSvn.SvnClient.Export(SvnTarget from, String toPath, SvnExportArgs args) in g:\\dist\\src\\sharpsvn\\commands\\export.cpp:line 66
at SimulationManager.Model.SubversionInterface.Export() in C:\\Users\\phines\\Documents\\Projects\\SimulationManager\\SimulationManager\\SimulationManager\\Model\\SubversionInterface.cs:line 43
I suspect this is due to a reliance on the presentation framework, but would still like to know if there is a way to get this working in a GUI-less way.
The errors with IEFrame and SHLWAPI are normal problems that depends reports as errors, but do not acutally cause the error. In my case, the error was caused by using SharpSVN in a non-user interface project. When moved to a WPF project, it worked as expected.
I have changed strategies to call a command shell "svn" application to achieve UI-less automation.