Joao Carlos Rafael
Joao Carlos Rafael

Reputation: 45

C# app doesn't work in other computers

Why does my app compiled with C# not work on other computers?

I have the .Net Framework 4.0 already installed.

When I open my .exe on another computer, I get the error:

ERROR SIGNATURE:

    Event Type: clr20r3  
    P1:         myapp.exe 
    P2:         1.0.0.0
    P3:         502051f 
    P4:         myapp 
    P5:         1.0.0.0 
    P6:         502051f 
    P7:         2 
    P8:         6 
    P9:         System.IO.FileNotFoundException

Upvotes: 1

Views: 5314

Answers (5)

David I
David I

Reputation: 931

I had exactly the same problem and like Joao eventually found it was caused by the Windows Forms LineShape. This adds the Microsoft.VisualBasic.PowerPacks reference to your project. When you then run it on a system that doesn't have the PowerPacks installed you just get that unhelpful System.IO.FileNotFoundException error with no clue as to which file is missing.

Yes I know this should get fixed up if you go the trouble of making a proper distribution setup which will prompt the user to install ..., etc, etc. But I just want to be able simply to copy my EXE to another system.

To solve: remove any LineShapes from your form and then remove the refences to VisualBasic and VisualBasic.PowerPacks in your references.

David

[Using VS2008 SP]

Upvotes: 0

JohnLBevan
JohnLBevan

Reputation: 24420

It looks like your program's missing a DLL (or the DLL's been misplaced):

http://social.msdn.microsoft.com/Forums/pl-PL/clr/thread/782217a8-46bd-4371-9915-28655d9b2c2f

Deciphering the .NET clr20r3 exception parameters P1..P10

A simple way around this would be to create a setup project - this will then bundle your project's dependencies into an install file. I don't think that option's available if you're on Visual Studio Express edition though. . .

http://www.dreamincode.net/forums/topic/58021-deploying-a-c%23-application-visual-studio-setup-project/

If you're pretty sure it's a .net framework that's missing, the following tool will show you what's on your machine / your client's, so you can figure out what's missing:

http://www.asoft.be/prod_netver.html

Hope that helps.

Upvotes: 0

Charleh
Charleh

Reputation: 14012

Most likely the app is trying to load an assembly and is failing to find it

A little off topic but ideally with any application you want to add some 'unhandled' exception handling to write to a log file or the event log so that you can capture more of the exception stack.

Often you only get the last exception message and you also don't see the call stack

You can roll up exceptions quite easily using something like this:

string RollupException(Exception ex)
{
    StringBuilder sb = new StringBuilder();

    sb.Append(ex.Message);

    while(ex.InnerException != null) 
    {
         sb.Append(Environment.Newline);
         sb.Append(ex.Message);
         ex = ex.InnerException;
    }

    return sb.ToString();
}

You can also use the EventLog class to write to the event log.

Info here:

http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx

Check out the examples - remember to register an event source first!

Upvotes: 0

swiftgp
swiftgp

Reputation: 1015

It sounds to me like a case of missing references. Check your references from the solution explorer or go into bin/debug or bin/release (depending on your configuration) and make sure to copy all the dlls or exes that your project depends on

Upvotes: 2

DGH
DGH

Reputation: 11539

A system.io.filenotfoundexception usually means your program tried to open a file that wasn't there. It is likely that your program is trying to access some file using a path or filename that doesn't exist or is in a different location on other computers. Without knowing what myapp.exe is supposed to do, I can't answer any further.

Your solution is probably to re-write your app so that it handles that exception better in some way, such as by checking for the file's existence before trying to open it.

Upvotes: 3

Related Questions