I have a problem running a C# application(WPF, .Net 4.0, Visual Studio 2010) targeted to x64 and uses 64bit dll (3rd party).
The problem appear when I run the 64bit version with 64bit dll(on 64bit Win7/WindowsServer2003). The application start OK. But when I hit start button on the app, where the app create thread and start interacting with the dll, the thread will crash/stop at the first call to dll function.
Below is the error generated, when I close the app.
Problem signature:
Problem Event Name: APPCRASH
Application Name: DelayServer.exe
Application Version: 1.0.0.0
Application Timestamp: 52092104
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.17965
Fault Module Timestamp: 506dcae6
Exception Code: e0434352
Exception Offset: 000000000000bccd
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 2057
Additional Information 1: 7315
Additional Information 2:
73159f4fb34892aabcc4ba245f14f64e
Additional Information 3: d5ec
Additional Information 4:
d5ec134b8e354c23783e48c0e2e572da
I understand that this is possible if there is a mismatch between the EXE and DLL i.e. EXE being a 32bit and DLL being 64bit or vice versa.
Attached is the screenshot of my settings. I didn't find a way to verify/edit my x64 platform settings.
x64 Project Build Settings screenshot
My Development computer is Win Vista 32bit and I have installed 64bit compilers.
I have 32bit targeted application using 32bit dll working OK on 32bit comupters.
The crash happens when I run 64bit targeted application with 64bit dll on 64bit computer
I tried dependencywalker, but I can't expland further to find any dependencies.
Can someone please help me with this.
Many Thanks
Sam
I have finally resolved the problem.
When I used Microsoft Debug Diagnostic Tool (from http://www.microsoft.com/en-gb/download/details.aspx?id=26798) the crash dump shows that there is a problem loading my external dll or its dependencies. I then loaded the my external dll into Dependency Walker (http://dependencywalker.com/) it shows that it can't find a dependency "msvcp100.dll" which is linked to Microsoft VC++.
So I installed Microsoft re-distributable package (x64) and my app doesn't crash any more.
Thanks every one for your help...
Related
I received an error report regarding a WPF app that wouldn't start up in a Windows Server 2008 Service pack 2 server (the application is an administration tool we're distributing to our customers). Since this application has a lot of external references, I tried to simplify the problem by creating a simple WPF application using Visual Studio 2013: a plain white window with "hello world" showing and nothing more. I tried to make it run in the production server, with no luck: it always crashes immediately.
Here's what I have:
the application was created with the standard VS 2013 template for WPF, so it had 3.5 as the target framework; i changed it to 4.6
the server has the 3.5 SP1 and 4.6 versions of the .net framework installed
the app.config is well-formed, with the configSections section on top, no additional references besides log4net, supportedRuntime tag set according to the target framework version
I already checked that there are no project references from version 3.5 left in the project
I already tried logging in the DispatcherUnhandledException and in the AppDomain.UnhandledException handlers
the application runs in my development environment
the application runs in production environment only if I change the target framework to 3.5. In this case, the WPF windows shows up and the log file is correctly produced
I already tried producing a dump and trying to debug it in Visual Studio: I just get a "Source not available" message and a stack trace ending with ntdll.dll!NtWaitForSingleObject()
Here are the error details:
Description:
Stopped working
Problem signature:
Problem Event Name: APPCRASH
Application Name: MyApp.exe
Application Version: 1.0.0.0
Application Timestamp: 5bfc07f1
Fault Module Name: KERNEL32.dll
Fault Module Version: 6.0.6002.24367
Fault Module Timestamp: 5ae3dcd9
Exception Code: e0434352
Exception Offset: 000000000001667d
OS Version: 6.0.6002.2.2.0.272.7
Locale ID: 1033
The Windows event log shows little information:
Faulting application MyApp.exe, version 1.0.0.0, time stamp 0x5bfc07f1, faulting module KERNEL32.dll, version 6.0.6002.24367, time stamp 0x5ae3dcd9, exception code 0xe0434352, fault offset 0x000000000001667d, process id 0x%9, application start time 0x%10.
Application: MyApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: exception code e0434352, exception address 0000000077A6667D
Stack: [this is empty]
Any suggestions?
Just in case someone else stumbles on the same problem, looks like the KB4457921 update from Microsoft somehow solves the issue. If an update is not possible, consider porting the code back to .net framework v. 3.5.
So there are couple of questions asked on this matter. There's x86, x64 secondary project that references another project created on x86 and based on a third party .dll built on x86.
The entire DLLImport and marshal call com wrapper was created using an upgrader tool. It upgraded VB6.0 into .Net code. The final .exe is installed and run in every PC as long as it is released using a x86 build. But it fails when build is on AnyCPU configuration.
When AnyCPU build is done and programme is executed the code keeps throwing an error on third party .dll and complaints it can't find the .dll. None of these issues persists when build is on x86. This is a practical issue as the application is meant for a device on Windows Embedded Standard OS and most Windows OSs from Windows XP onwards.
Error :
System.DllNotFoundException was unhandled HResult=-2146233052
Message=Unable to load DLL 'posLTD.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=ProjectOne TypeName="" StackTrace:
at PorjectOne.PInvoke.UnsafeNative.POSLTD.ConnectToDevice(Int32 nMachineNo, String& strIpAddress, Int32 nNetPort, Int32 nTimeOut, Int32 nProtocolType, Int32 nNetPassword, Int32 nLicense)
What can be done to solve this? Could this be the device OS compatibility issue?
Some of the third party libraries are created in such way, that they can not be compiled for any other architecture.
For example, at least theoretically you could use exactly same part of code in x86, x86_64 and ARM(eg. Universal App), if you wrote it from scratch using .NET. But if the library is compiled only for x86(be it bad will of developer or optimalization), it can only be used by applications with same architecture. A fine example of this is SQLite, which is a pain in the back for any Windows Phone 8 developer - you must have both x86 for debug in emulator and ARM for production(AFAIK, at least we never found a way to have only one).
I have a 32bit compiled dll that contains vb6 code. On my previous os, which was windows 7 64bit, i was able to register and run this dll fine within my c# application. Now, running windows 8.1, when i try to register the same dll, it registers fine, however when i try to read the dll in my code, i get:
Retrieving the COM class factory for component with CLSID
{D19A00C4-A7F9-4E14-A5E1-D060B7EB57F3} failed due to the following
error: 80040154 Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG)).
The 32bit dll (compiled as Interop.VB6Class) is used in a c# class
that is build against x86.
I have tried both regasm from my 64bit folder and the 32bit folder, no luck
When i run Dependency Walker (a nice little application that checks if all your dll's dependencies are available and that your cpu version for the dll and its dependencies match), I still get the message "Modules with different CPU were found".
I have followed numerous links and advice, so if anyone can help me, I would accept you as my savior and forever call you king.
Just a suggestion, but are you 100% sure that your project settings are correct. Your Platform Target should be x86 and the Prefer 32-bit check box should be ticked. Also are you running the Debug version or the release version?. You need to set your 32 bit settings for both environments. For the command line version print out the following to ensure your environment is correct.
Console.WriteLine("OS {0}, Process {1}", System.Environment.Is64BitOperatingSystem, System.Environment.Is64BitProcess);
I know it's a long shot but it might help in finding the root cause of the problem.
I have developed a windows application in visual studio 2012 and deployed the application using Installshield. When I install the application in 32-bit system it works fine, but while I install in 64-bit system, it installs fine but after installing the application is not opening throwing and error that,
Problem Signature:
Problem Event Name: APPCRASH
Application Name: sappln.exe
Fault Module Name: KERNALBASE.DLL
and more it goes on..
In configuration Manager, I have specified Release -> Any CPU
Can anyone give some solutions to avoid this error?
Thanks in advance!!
Seems like you are using libaries that can't run on x64 platforms. What libaries are you using?
Also check if your program does anything "special" upon startup.
This should keep you out.
Good luck!
I've created a very simple console app in .NET 4.0 that will run as a scheduled task. It looks for local files that are unmodified for a certain amount of time and then parses the file, inserts a record into a MySQL database, and copies the file to the network. I'm using a local SQLite database to track which files have already been processed, but unfortunately I'm running into a problem on one system at the first SQLite operation:
System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) File name: 'System.Data.SQLite.dll'
at FileDatabase.CreateDatabaseAndTable()
at Program.Main(String[] args)
This exception is thrown on one system (Windows 7 x64 Home Premium with .NET 4.0 full), but is not thrown on two other systems (dev system + one other, both Windows 7 x64 Professional with .NET 4.0 full).
From browsing other questions, I see that this can happen when the program is run in 64-bit mode since the SQLite DLL is the 32-bit version. The first thing I checked is that the active platform is x86 in the Visual Studio Configuration Manager. I also used IL DASM to verify that the output exe is 32-bit (.corflags 0x00000003 // ILONLY 32BITREQUIRED). I would prefer to keep the 32-bit SQLite DLL and target platform as x86 so that I do not have to make different versions of the application for 32- and 64-bit computers.
I've also read that this exception can occur because of a corrupted DLL file, but since it works on some computers, I think this is not the case.
Other things I've tried on the problem system that didn't help:
Searching the GAC and Windows directory for errant SQLite DLLs, but found none.
Turning off AVG anti-virus.
Running the exe directly instead of the published ClickOnce application.
Uninstalling and reinstalling the ClickOnce application.
Any suggestions would be appreciated - thanks!
Installing the full setup package from system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki seems to have solved the problem - it must have been some dependency that was not present (possibly in Windows 7 Professional but not Home?). While this solution isn't perfect for a big deployment, I really just needed it on this one computer. Thanks for RoadBump for getting me on the right path.