Unable to load dll file - exception 0x8007007E - c#

I'm working with National Instruments Measurement Studio in C#, and I've come across a bit of a problem in deploying my application to a particular computer (running Windows 7). I've tried asking on the National Instruments forums, but haven't got any solutions yet - could anyone here give me some tips?
Essentially, I have deployed this application several times on a number of computers, but in this particular case I receive an error when running the program -
"System.DllNotFoundException: Unable to load DLL 'nianlys.dll': The specified module could not be found. (Exception from HRESULT: 0x80070007E)
I have ensured that nianlys.dll is present in C:\Program Files
(x86)\National Instruments\Shared\Analysis.
I have ensured that libiomp5md.dll and LV110000_BLASLAPACK.dll, the files from mkl.msm (nianlys.dll has a dependency on mkl.msm), are present. nianlys.dll also has a dependency on nimetautils.msm, but I'm not sure which dlls are included in this.
I have ensured the program is installed by running the setup.exe as an administrator (as opposed to running the .msi that is generated, see here).
I have ensured the computer in question is up to date with updates to the .net framework via windows update.
I have tried reinstalling the program several times, sometimes with a freshly-recompiled installer.
I have tried adding in the 64 bit nianlys.msm into the setup project manually - this throws an error because the TargetPlatform property of the setup project is set to x86. The 32 bit version is, of course, already present in the detected dependencies.
Interestingly, taking a copy of nianlys.dll from C:\Program Files (x86)\National Instruments\Shared\Analysis and inserting it into the directory the program is installed in throws up a different error - in this case, the error is:
"An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"
Taking a copy of the 64 bit version of nianlys.dll from another computer (default location C:\Program Files\National Instruments\Shared\Analysis) and inserting it into the directory the program is installed in throws up a third type of error - "System.DllNotFoundException: Unable to load DLL 'nianlys.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)". It should be noted that this .dll was present before installing the program on the machines that the program works on, but is not present on the target computer that is throwing up problems.
Taking the same 64 bit nianlys.dll and inserting it into the location it was found on on another computer, C:\Program Files\National Instruments\Shared\Analysis, does not solve the original error.
Even more interestingly, I have tried to reproduce the error on a computer on which the program works - removing the x64 version of nianlys.dll throws up the original HRESULT: 0x80070007E error, whereas removing the x86 version causes a windows installer to appear when running the program.
On a computer upon which the program works with no problems, the windows task manager does not seem to indicate that the program is 32 bit (with the *32 suffix on the program name), despite the target platform being set to x86. It seems from all this that there is some issue with the nianlys.dll being used in both its x64 and x86 versions, despite the target platform only being x86.
I'm running out of ideas about what kind of thing I could try to solve this problem.

I suspect that even though the setup is for X86, the project itself is AnyCPU and thus runs as a 64bit process on 64bit systems and as a 32bit process on 32bit systems. As you said your DLL is in the Program Files (x86) folder I assume it is 32bit only, so you should compile your application explicitly as x86, too. It is your bullet #7 that leads me to this conclusion.
Just copying the nianlys.dll 64bit DLL doesn't seem to work as it seems to rely on other DLLs it then can't find. (bullet #8).

It may caused by the dependents of nianlys.dll are not found. You can diagnose this problem with the process monitor , one of the system internal tools. It can capture the loading/unloading DLL activities, so if something wrong, you can find it in the log.
Be sure to use the filter when use this tool, otherwise the log file will be huge.

Related

Using a 32bit COM-object in a 64bit environment

The code below executes without problems in a 32bit c#-application.
object obj = system.Runtime.InteropServices.Marshal.GetActiveObject("Due.Application");
var due = (Due.IDueApplication2)obj;
Now, I try to get the same code working in a 64bit c#-application and therefore I followed the instructions at
http://www.gfi.com/blog/32bit-object-64bit-environment/ or http://www.codeproject.com/Tips/267554/Using-bit-COM-Object-from-bit-Application
Two cases when running the 64bit application
Due is not running and the first code-line fails with HRESULT: 0x800401E3 (MK_E_UNAVAILABLE). That's fine and happens in the 32bit version as well.
Due is running and in the first code-line obj receives a COM-object. But then, the second code-line throws an InvalidCastException because QueryInterface fails with HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG). (Obviously, this works in the 32bit version.)
Q What must I do, to make the cast in the 2nd code-line to succeed?
Edit As suggested by #HansPassant, I fired up the ProcessMonitor and monitored both the 32bit and 64bit application. I observed that the 64bit application when executing GetActiveObject (1st code-line) omitted accessing a COM-object specific dll (CreateFile, QueryBasicInformationFile, QueryNameInformationFile, ...) which in contrast the 32bit application did, even though I've added the according registry entries beforehand, i.e. AppID, DllSurrogate.
Edit1 I removed all the registry-entries I added and double-checked the results including the log-files of the ProcessMonitor. I didn't notice any difference - same symptoms as before.
Update In the directory of the 3rd party software I found a Due.tlb and I tried to create a runtime-callable-wrapper as hinted in 64 to 32 bit Interop - how?.
I created an Interop.due.dll with tlbimp.exe Due.tlb /out:Interop.due.dll. Unfortunately, when I replaced the original 32-bit Interop.deu.dll with the newly created platform-agnostic one my solution failed to compile (missing references).
The only thing which worked was an out-of-process solution. I implemented a 32-bit WCF-service which provides the access to the COM-objects for the 64-bit process. (Hence, I implemented the proxy myself.)
ad Update
good news
By utilizing the information in this post I was able to regenerate a platform agnostic version of the Interop.due.dll. Even though, TlbImp.exe warned me with warning TI3002 : Importing a type library into a platform agnostic assembly. This can cause errors if the type library is not truly platform agnostic.
bad news
The promised glue code was not provided and therefore the bridging of 64bit and 32bit did not work out. (The 32bit only version worked as before.)

Log4net.dll + C# + Crystal Reports = error

Forgive me if it has been answered before but I searched the web and found only desperate people asking exactly my question but nobody giving any answer which I could use.
I'm developing an application in C# Visual Studio 2010 which uses Crystal Reports. I'm developing it on 32 bit system. Everything works okay.
Now I'm trying to run it on another computer which is 64 bit system has Crystal Reports installed and some terrible error happens.
************** Tekst wyjątku **************
System.TypeInitializationException: Inicjator typów zgłosił wyjątek dla typu
'CrystalDecisions.ReportSource.ReportSourceFactory'. ---> System.TypeInitializationException:
Inicjator typów zgłosił wyjątek dla typu 'CrystalDecisions.Shared.SharedUtils'. --->
System.IO.FileLoadException: Nie można załadować pliku lub zestawu
'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' lub jednej z jego zależności.
Forgive me some Polish language there. It basically means that it cannot find some specific version of log4net.dll file which apparently must be used by something.
This problem was described in many places:
log4net not logging and throwing error
http://scn.sap.com/thread/1857957
I understand that my application uses/expects some version of this file and Crystal Reports installed on 64 bit machine uses another version.
Still after browsing the internet I have no idea what steps I should take to correct it.
I would be really grateful for some "tutorial for dummies" how to deal with it.
Oh, and my application needs to be built as 32 bit and run on 64 bit. No possibility of building it as 64 bit, another thing would stop working :(
Installing CR 32 bit (CRRuntime_32bit_13_0_14.msi) will resolve the error.
The 32 and 64 bit versions can be found here.
Well, not much response here :) I've learnt a few things myself since then and have thought I would share my knowledge with any poor beginner people that may encounter the similar problem.
So there is something like GAC - http://en.wikipedia.org/wiki/Global_Assembly_Cache
You may think of it as a collection of libraries and drivers used by your programs.
It is on your computer in c:/windows/assembly but it is a hidden directory so first you must enable seeing it.
At my 64 bit computer it contained GAC_32 and GAC_64 subdirectories. In GAC_64 there was log4net in:
c:\Windows\assembly\GAC_64\log4net\1.2.10.0__692fbea5521e1304\
In GAC_32 there was nothing. So I created the directory and copied the appropriate file from my 32 computer into it and it worked.
c:\Windows\assembly\GAC_32\log4net\1.2.10.0__692fbea5521e1304\
Still a moment later I faced another error but it is a different story
CrystalDecisions.CrystalReports.Engine.ReportDocument'. ---> System.IO.FileNotFoundException: Nie można załadować pliku lub zestawu 'CrystalDecisions.ReportAppServer.CommLayer, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
Generally expect that anything using Crystal Reports build on 32 bit computer may give problems when tried to run at 64 bit computer. SAP did really a crappy job with these drivers.
Do you have SAP Crystal Reports runtime engine for .NET framework (64-bit) installed on the target machine? If not, you may try installing it from this link and see if it will fix your problem.
Also, if you have installed only the 32bits version on a 64 bits platform, you'll get the same Log4net error; both version, 32 & 64 bits, are required.
It's curious that 64bits msi delploys DLL in SAP 32bits folder (C:\Program Files (x86)\BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\ ) that 32bits setup doesn't.
In my case, installing CR 64-bit wasn't an option, but I was able to work around this issue by enabling 32-bit application on the App Pool in IIS. (See this answer).

BCL.XPRB dll isn't initializing in C#.Net application

I am trying to resolve an initialization error for the optimizer library. I have a license for and installed Xpress-IVE 64bit studio, however, I need to link and use xprb facilities in a C#.Net application that is built in VS2010 and runs on IIS.
I copied xprb.dll and xprbdn.dll to application bin folder for deployment, and added them as references. Yet when the application calls XPRB.init(), it throws exception
Unable to load DLL 'xprb.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
Any suggestions on what could be missing?
It turned out to be a Windows/.Net/general instability issue. The license, although installed, wasn't found by .Net, which decided to blow up as if the dll wasn't available. Finally was resolved mysteriously after a few system reboots and updates.
I had the same issue, but running windows 8.1, xpress-ive 64bit and vs2013 with c#. I could run IVE and solve problems from there, but i got "An unhandled exception of type 'Additional information: Unable to load DLL 'xprb.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" error in runtime when running using bcl in VS. What solved the problem in my case was going through the necessary environment variables and directing them to the correct xpress folders (environment variables xpress, path and mosel.dso).

Sybase driver error in 64 bit windows server

I have a console application which works perfectly in 32 bit machine. But I'm having problem running the executable in 64 bit windows server. The error message I get is:
The type initializer for "Sybase.Data.AseClient1.AseConnection" threw an exception. System.BadImageFormatException. An attempt was made to load a program with incorrect format. at Sybase.Data.AseClient.Unmanaged.AseGetDriverVersion at Sybase.Data.Aseclient1.AseConnection.CheckVersion().
Has anyone seen this error?
Update: After compiling in X86, I get:
Major version mismatch sybdrvado20.dll. Expecting major version '2'. Loaded version 1 at Sybase.Data.AseClient1.AseConnection.CheckVerison.
Please note that the server has latest Sybase version.
Even easier, download the x64 version http://www.sybase.com/detail?id=1051287&elq=00000000000000000000000000000000
I had similar problems, because the driver is 32 bit. so try to build your application for x86. You can do this in your project properties.
Regarding the error "Major version mismatch sybdrvado20.dll...", what solved for me was replacing the old version of sybdrvado20.dll that was in the bin folder of my application (located in the server) for the new one, located in C:\Sybase\DataAccess\ADONET\dll or C:\Sybase\DataAccess64\ADONET\dll.
To check the version of the dll, right-click the file, go to Properties and click in the tab Details.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Expression.Encoder.Utilities.dll'

i just wrote a program that uses microsoft encoders and merge videos and audios , its working fine in my PC (Windows7 ) and when i test it on other PCs (Windows7,Windows XP [.net 4.0 installed]] it is giving me following exception
its even giving me exception when i try to run the sample sdk applications to other pcs ..(with no microsoft expression installed)
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'Microsoft.Expression.Encoder.Utilities.dll' or one of its dependencies. T
he specified module could not be found.
at Simple.Program.Main(String[] args)
how can i solve this error ,
or what are the ways to deploy standalone application , without pc pre installed microsoft expression studio.
thanks
Microsoft.Expression.Encoder.Utilities.dll is part of Expression Studio. If it isn't installed on the target machine it will not be found.
I don't know if these DLLs can be freely distributed, but you should find out before trying to distribute them with your application.
try to locate this dll-file on your machine, and distribute it with your executable to a pc that hasn't got expression installed.
when a program is about to use a dll, it looks in some predesignated places on the computer. one of the first places is in the folder the executable is executed in. one of the later places is probably c:\windows\system32
you have the filename though, so it shouldn't be that hard. unless microsoft has created some sort of mechanism stopping the distribution of the expression utilities.

Categories