2

Hello I've created a WinForms application that I'm ready to implement on other computers (outside of mine). I've having problems running it elsewhere.

In the Program.cs file I've got this to see what the problem is:

static void Main()
{
   try
   {
       Application.EnableVisualStyles();
       Application.SetCompatibleTextRenderingDefault(false);
       Application.Run(new mainForm());
    }
    catch(SystemException ex)
    {
       MessageBox.Show("Error: ", ex.ToString());
    }
}

Nothing it edited here besides the addition of the try/catch. I know the problem is in this Program.cs because I've got a series of message boxes are set to show in different stages of the MainForm_Load() block. The application reaches none of them.

This probably sounds really vague, but I simply cannot get this application to work anywhere other than my laptop. Would it be one of the Usings I've got? I can include those if needed.

Edit 2: As per Marko's suggestion, I copied all the external DLLs in the same root folder as the EXE I'm trying to run. The 3rd try-catch block is throwing the exception from the Program.cs which is Application.Run(new mainForm()); and I traced this to the 32nd line of my mainForm.cs. On this line I have my background worker:

private BackgroundWorker snBW = new BackgroundWorker();

are we any closer?

ikathegreat
  • 2,311
  • 9
  • 49
  • 80
  • what is your target framework ? – Royi Namir May 26 '12 at 17:49
  • Can you paste the whole part of `Problem Signature` message.This generally happens when a referencing dll not found. Which .NET framework your project targets to? – Rahul May 26 '12 at 18:03
  • 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 May 26 '12 at 18:19
  • thanks for the responses. my application is using .NET Framework 4 Client Profile, according to the info page. I'm using VS2010, should I be using a different framework for more universal use? Is there a way to check (when I publish and create the installer) if the required components are installed? – ikathegreat May 26 '12 at 18:33

3 Answers3

2

Great and cool question.

Sometimes application fail because of missing, corrupted or turned off target framework version. You can see what framework your application requires, full or client profile and install it before usage.

Problem with corrupted framework often happens to .Net 2.0 because of broken Microsoft update for that component. It happens on different machines from time to time. Solution is to reinstall framework.

Issue with deactivated .Net 3.5 feature happens on Windows 7, 2008 Server sometimes. It can be activated in Features of Windows.

Many .Net 3.5 applications actually requires .Net 3.5SP1.

Siarhei Kuchuk
  • 5,296
  • 1
  • 28
  • 31
  • so on my test client machine, I see in the installed programs list .NET Frameworks for 1.1, 3.5 SP1, and 4 Client Profile. because my application is set for 4 Client Profile, should I continue to search elsewhere for the problem? – ikathegreat May 26 '12 at 18:46
  • What's the operating system and its bitness? What's the bitness of your application? – Siarhei Kuchuk May 26 '12 at 18:55
  • I wrote this on Win7 Professional x64 laptop. I've tested on an identical desktop as well as an x32 Vista (don't' know why). – ikathegreat May 26 '12 at 18:58
  • 1
    Please try to set x86 to debug/release targets of app with its libraries and retry. Also please try to reinstall .Net 4 Client and reboot and that machine. – Siarhei Kuchuk May 26 '12 at 19:00
0

First, check if you've got appropriate .net framework installed on the computer. Second, if you're using any external libraries, be sure to copy all required dlls to the application folder.

Marko Juvančič
  • 5,792
  • 1
  • 25
  • 41
  • is this automatically done when I publish the application from VS2010? If not, doesn't that mean I'll have to go about my computer and fetch a copy of all the DLLs I'm using in there respective places? (Lame?) – ikathegreat May 26 '12 at 18:37
  • Hm... Which external libraries do you use? Go through your project's references and you'll get the dlls. – Marko Juvančič May 26 '12 at 18:40
0

The Form.Load event handler will not execute within the context of your outer try–catch block. UI events are effectively callbacks; you should declare a new try–catch block within each of their handlers for effective debugging.

Douglas
  • 53,759
  • 13
  • 140
  • 188
  • good idea. So I've added 3 separate try-catch blocks in the Program.cs. The error text is `System.Runtime.Interop.Services.COMException (0x80040154): Retreiving the COM class factory for component with CLSID (bunch of text) failed due to the following error: 80040154 Class Not Registered.` is there a good way for me to debug this? – ikathegreat May 26 '12 at 18:42
  • I would suggest opening a new question with the full error text. You should include the CLSID since it identifies the third-party COM component that is causing the issue (unless such information is confidential to your company). – Douglas May 27 '12 at 09:17