2

I have an open source C# app with a WiX installer, relying on .NET 4.5.

  • Windows7 64bit (with .NET 4.5 installed) users say it works fine.
  • Windows7 32bit (with .NET 4.5 installed) users say it crashes.

So I installed Windows7 32bit (in VirtualBox), installed the app, and indeed it crashes:

enter image description here

Problem Signature 09 is System.IO.DirectoryNotFound, and Windows' Event Viewer mentions C:\Windows\system32\KERNELBASE.dll, if that can give a clue.

Then I decided to install Visual C# 2010 Express on the same machine, and...
SURPRISE: The app does not crash anymore (neither the installed app nor when executed via Visual C#)

How to avoid this crash?
I can't ask all users to install Visual C#...

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
  • What directory is it looking for? You probably have some code that relies on some directory being present that is installed by Visual Studio. – jeroenh Nov 19 '12 at 07:17
  • 2
    What version of .NET are you relying on, and was that version of .NET installed in the test environment? (You don't need to install an IDE, but you *will* need an appropriate version of .NET.) – Jon Skeet Nov 19 '12 at 07:17
  • 2
    Try to gather more details about the error. Catch the exception and see what is the missing folder. – Amiram Korach Nov 19 '12 at 07:17
  • @JonSkeet: Updated question: .NET 4.5 installed everywhere – Nicolas Raoul Nov 19 '12 at 07:23
  • @AmiramKorach: My program actually catches any exception that might arise from my code: https://github.com/nicolas-raoul/CmisSync/blob/master/SparkleShare/Program.cs#L69 – Nicolas Raoul Nov 19 '12 at 07:26
  • Does it also crash if you compile your target application to x86 or x64 instead of AnyCPU (default)? – beta Nov 19 '12 at 07:32
  • Look in the Event Viewer for the crash, there you might find better exception details. Compiling the app with debug symbols to test might be a good idea to get better details. – Karl-Johan Sjögren Nov 19 '12 at 07:36
  • @Karl-JohanSjögren: The Event Viewer contains a bit of new info: it points at `C:\Windows\system32\KERNELBASE.dll` – Nicolas Raoul Nov 19 '12 at 07:42
  • @beta: Visual C# Express only has AnyCPU. Ref: http://msdn.microsoft.com/en-us/library/5b4eyb0k.aspx – Nicolas Raoul Nov 19 '12 at 07:49
  • Not sure whether or not this is possible in the Express edition either but in my company we usually just install the Remote Debugger on the target machine, copy the debug symbols over to another PC which has Visual Studio installed and remote debug the process to find out what's going on for that kind of problems. Probably faster than to trial/error. – beta Nov 19 '12 at 08:10
  • @beta: Unfortunately remote debugging is not available in Express either. Ref: http://blogs.msdn.com/b/lukeh/archive/2004/07/01/171213.aspx – Nicolas Raoul Nov 19 '12 at 08:21
  • @NicolasRaoul I think the exception is due to the `System.Data.SQLite.dll` assembly that your `SparkleLib.Cmis` project references. One reason is that library has some native code dependencies including Visual C++ runtime components (which might get installed with VS Express). This page on System.Data.SQLite packages might be of some use: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki – Mike Zboray Nov 19 '12 at 08:28
  • @mikez: That was it! Could you please make your comment an answer, so that I can accept it? Thanks a lot! – Nicolas Raoul Nov 20 '12 at 03:09

2 Answers2

1

This is just a guess since I don't have all the information at hand. But CLR20r3 is the Common Language Runtine 2.0 revision 3, so I have three possible solutions. Of which I have encountered all during regression testing of one of our main products.

Packaging

You are not packaging all the required dll's, (ergo "File not found") but they are shipped with the development environment. Set copy-local to true in Visual Studio.

.NET version

The client does not have .Net 2.0 installed and therefore CLR20r3 fails (also "File not found").

Target application platform

Some third party dll's do not work will all configurations, so I might be worthwhile to check if it works with or without the "any-cpu" bit set in the executable. (Ie build towards x86 or x64 and do not use "any-cpu" in Visual Studio).

Update

After some googling about this specific case I believe the .NET version is the issue, especially since both P2 and P5 (Exe File assembly version number and Faulting assembly courtesy of Deciphering the .NET clr20r3 exception parameters P1..P10) are 0.0.0.0. The application does not load simply because a file is missing, and is this case I guess it is a file belonging to a .NET framework version other than .NET 4.5.

Community
  • 1
  • 1
flindeberg
  • 4,887
  • 1
  • 24
  • 37
  • .NET: All users (and all of my test environments) have .NET 4.5 installed. – Nicolas Raoul Nov 19 '12 at 07:51
  • Third party DLLs: Great hint, I will now check the few DLLs I ship. – Nicolas Raoul Nov 19 '12 at 07:53
  • @NicolasRaoul .NET 4.5 does not include .NET 2.0, they are "separate". And regarding packaging, you might only ship the x86 version of a dll. It all depends on your setup :) Kernelbase points towards build issues though. Please update your question with that information so it's not only in the comments. – flindeberg Nov 19 '12 at 07:57
  • I checked all DLLs using the Perl script at http://stackoverflow.com/questions/495244 : All DLLs are i386 – Nicolas Raoul Nov 19 '12 at 08:00
  • @NicolasRaoul Then my best guess would be the .NET version, do they have 2.0 installed? I'm very sure that it is the assembly version though, since both **P2** and **P5** are *0.0.0.0* it means that something probably went wrong the initial loading of the assembly/CLR. – flindeberg Nov 19 '12 at 08:14
  • Do you mean users have to install both .NET 4.5 and .NET 2.0SP2? My understanding was that Windows7 out-of-the-box includes anything that 2.0SP2 provides: http://msdn.microsoft.com/en-us/library/bb822049.aspx – Nicolas Raoul Nov 19 '12 at 08:38
  • @NicolasRaoul That does seem correct though, so now I'm confused :) Do you use a blend of .NET 4.0 and .NET 4.5 libraries? Can you check the .NET versions of all libraries you are referencing? – flindeberg Nov 19 '12 at 08:43
1

I'd call this more of a hunch than an answer, but it seems to have helped. I'll just go through my though process.

Based on the fact that the app works on 64-bit and not 32-bit I am immediately thinking BadImageFormatException or an incorrectly coded path looking in Program Files (x86) (or something similar with 64-bit/32-bit registry values). But then we learn everything is fine with VS installed, which is odd. So, I start looking at the proj files and references. Almost all of it is managed code/MSIL so it doesn't seem like it's anything that could be related to a 32-bit/64-bit issue. In one of the reference projects (SparkleLib.Cmis), however, I see a reference to System.Data.SQLite which I know has unmanaged components. I googled the docs. They mention this:

All the "static" packages contain either native or mixed-mode assembly binaries linked statically to the appropriate version of the Visual C++ runtime. Typically, these packages are used in cases where customer machines may not have the necessary version of the Visual C++ runtime installed and it cannot be installed due to limited privileges.

So I'm pretty sure at this point, its an improperly deployed System.Data.SQLite that happened to work on the dev box because VS is already there. OP has confirmed that this is indeed the issue.

Mike Zboray
  • 39,828
  • 3
  • 90
  • 122
  • Indeed! The right SQLite DLL to use were the ones in the `Precompiled Statically-Linked Binaries for 32-bit Windows (.NET Framework 4.0)` paragraph. I was mistakenly using `Precompiled Binaries for 32-bit Windows (.NET Framework 4.0)`, I should have read more attentively its description which says `The Visual C++ 2010 SP1 runtime for x86 and the .NET Framework 4.0 are required` – Nicolas Raoul Nov 20 '12 at 05:11