0

I developed an application with Visual Studio 2013 and it works fine. I can even move it to other directories, so all paths used in the application are relative!

Now unfortunately it only works on the developer's computer and not on others. So I guess, there is a missing .dll or something.

This is the error message I get:

>     Problem signature:
>       Problem Event Name: CLR20r3
>       Problem Signature 01:   MyApp.exe
>       Problem Signature 02:   1.0.0.0
>       Problem Signature 03:   53314d38
>       Problem Signature 04:   PresentationCore
>       Problem Signature 05:   4.0.30319.18408
>       Problem Signature 06:   52313210
>       Problem Signature 07:   1b7e
>       Problem Signature 08:   0
>       Problem Signature 09:   System.BadImageFormatException
>       OS Version: 6.1.7601.2.1.0.256.4
>       Locale ID:  2055
>       Additional Information 1:   0a9e
>       Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
>       Additional Information 3:   0a9e
>       Additional Information 4:   0a9e372d3b4ad19135b953a78882e789
Martin G
  • 17,357
  • 9
  • 82
  • 98
SoBiT
  • 408
  • 5
  • 18
  • Check : http://stackoverflow.com/questions/9244694/c-sharp-windows-appication-event-clr20r3-on-application-start btw, google will help aswell ;) – Menno van Leeuwen Mar 25 '14 at 11:41
  • 1
    possible duplicate of [Deciphering the .NET clr20r3 exception parameters P1..P10](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10) – Hans Passant Mar 25 '14 at 11:49

2 Answers2

1

When I have run into this it typically is caused by the appropriate .NET framework not being installed.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
1

Please make sure that... 1- you set CopyLocal - true for the assemblies you are referencing in your program and those assemblies are available in current directory 2- you added a reference in your application that doesn't exists in GAC of the target machine. 3- If .net framework version is the same as you used to develop your application, there is a possibility that any un-managed component is referenced that is not working on target machine.

ak1
  • 387
  • 7
  • 20
  • Just wanted to add one more point. `BadImageFormatException` can also come when a DLL or executable is loaded as a 64-bit assembly, but it contains 32-bit features or resources. – Ray Mar 25 '14 at 12:02
  • CopyLocal is now set to true for all references. And .net framework was already installed on the target machine. But what is it about the GAC? I tried to understand it but didn't really see what this is for. I include 2 custom dll's, do I now have to add them to the GAC? Is this possible by code? – SoBiT Mar 25 '14 at 13:08
  • Please explain what do you mean by Custom dlls, are those dlls are managed assemblies? if yes and those assemblies are available on execution path of your application, then there could be some other issue. What I meant for GAC is that there is a possibility that you referenced any assembly that was available in your dev machine and is not available in the GAC of target machine. Secondly to add assembly to GAC programmatically pfl [link](http://blogs.msdn.com/b/helloworld/archive/2008/09/22/how-to-install-assemblies-to-the-gac-programmatically.aspx) – ak1 Mar 25 '14 at 13:21
  • Ok, I'm pretty sure, that I found the problem. I use the "System.Data.SQLite.dll" and on their website you can find the following information: "The final step is to identify the target processor architecture on both the development and customer machines. – SoBiT Mar 25 '14 at 13:34
  • x86 binaries work on an x64 machine running Windows. However, there is a problem when using managed code. If the executable that starts the process consists entirely of managed code, it will run with the native processor architecture of the machine, which will be x64 on an x64 machine. Later on, this will cause assemblies containing any native code compiled for x86 (e.g. the "System.Data.SQLite.dll" mixed-mode assembly, the "SQLite.Interop.dll" native interop assembly, or the "sqlite3.dll" native library) to fail to load, typically resulting in a BadImageFormatException being thrown." – SoBiT Mar 25 '14 at 13:34
  • But I can't find a solution for this. I'm developing on x64 and my target computer is x86, but I changed the project settings to x86 – SoBiT Mar 25 '14 at 13:36
  • 1
    and another important thing, you don't need to set CopyLocal True for all the references, just set it for those references that are not part of .net framework and came from third party. – ak1 Mar 25 '14 at 13:37
  • 1
    i would suggest to use the option "Any CPU" – ak1 Mar 25 '14 at 13:39
  • in case if you are referencing sqllite assemblies, which don't have 64 bit versions, download the source code and build for 64bit. – ak1 Mar 25 '14 at 14:05
  • I don't think that I'm using any 64bit assemblies. And why would I even need them? Didn't they say, that SQLite for 32bit also works on 64bit machines? And as I said, it works on 64bit but not on 32bit. I'll check if it works on a 32bit target computer and give you feedback. – SoBiT Mar 25 '14 at 14:29
  • Ok, I just tried to use the app on another 64bit computer and this worked, so it's definetly an issue with 32bit – SoBiT Mar 25 '14 at 14:48