-1

We recently finished a VB.Net application, but encountered difficulties after deploying it.

When I run it on my computer (or any other workstation with Visual Studio installed), it works fine. The splash screen appears, it prompts for the database info, and then the main screen shows. When it's run on any other workstation, it crashes on launch. The splash screen appears, and a moment later Windows informs us "EP.exe has stopped working"

I've looked through the event log and error reports, and the only useful information I've been able to extract is the fatal error is System.IO.FileNotFoundException. This doesn't help me - it doesn't say what file isn't found, and EP doesn't touch the file system until much later. (Two forms deep off the main menu; after you select a file to import).

What can cause this error?
How can I tell what file is missing?
Where do I put the file so .Net can find it on client workstations?

edit: I followed the instructions that @Visual-Vincent linked, but don't think I found anything useful. After disassembly, the error was in method 0x060004ac (the constructor for the Server Name form, written entirely by Visual Studio), with the specific line causing the error (IL_0037) being ldarg.0 (which as far as I can tell merely pushes an argument onto the stack). The statements before and after are nop and InitializeComponent(), respectively.

edit2: After reading the MSDN article on Unhandled Exceptions, I was able to get .Net to show me the details of the fatal exception ("Could not load file or assembly Microsoft. VisualBasic. PowerPacks. Vs...") which is something I think I can do something about.
* furiously typing *

Community
  • 1
  • 1
  • Are your dll's and config files where they are expected to be? – Neal Nov 07 '16 at 17:25
  • No config files. DLLs copied to the /bin folder were added to the local directory on the workstations. What else should I check? – Einstein X. Mystery Nov 07 '16 at 17:36
  • The event log error reveals more than just the error type. See: [**Deciphering the .NET clr20r3 exception parameters P1..P10**](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10). – Visual Vincent Nov 07 '16 at 17:44
  • 2
    You can also try subscribing to the [**`AppDomain.UnhandledException` event**](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx). When any unhandled error occurs (errors that will crash your application) that event will be raised and you'll be able to use .NET code to inspect all of its parameters. For instance you could serialize the exception and save it to disk, then read it on your own computer (binary serialization is the best for this). – Visual Vincent Nov 07 '16 at 17:48
  • Since it is apparently before or in the routine that prompts for database info, add some exception handling in appropriate spots and `MessageBox.Show(ex.Message)` in the `Catch` to see more info. – topshot Nov 07 '16 at 19:13
  • @topshot : My latest comment covers that, though for unknown positions in the code. If he doesn't know exactly where it happened then the exception in the event args of the `UnhandledException` event will (likely) tell him the location through the `StackTrace` property. – Visual Vincent Nov 07 '16 at 19:19
  • In response to your second edit: Perhaps [**this answer from Hans Passant**](http://stackoverflow.com/a/17134471/3740093) can help you. – Visual Vincent Nov 07 '16 at 20:36
  • Thanks @VisualVincent! Catching the AppDomain.UnhandledException let me track down what was missing, and setting Copy Local made it work. – Einstein X. Mystery Nov 08 '16 at 00:29
  • No problem, glad I could help! – Visual Vincent Nov 08 '16 at 07:36

2 Answers2

1

After pursuing the AppDomain.UnhandledException linked to by Vincent I was able to get the application working on user workstations.

    Dim currentDomain As AppDomain = AppDomain.CurrentDomain
    Sub MyHandler(sender As Object, args As UnhandledExceptionEventArgs)
        Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
        MsgBox(e.Message)
    End Sub
...
    Public Sub Main()
        AddHandler currentDomain.UnhandledException, AddressOf MyHandler
...

Turns out Visual Studio expected the Power Pack to be installed on the client computers. After adding "Copy Local" on the reference to Microsoft.VisualBasic.PowerPacks.Vs (and deploying the DLL to the client workstations) the application works now.

Community
  • 1
  • 1
0

You can use Process Monitor to troubleshoot such issues. Look for files that have "Path not found" and "Name not found". This may happen often, since Windows might not find the file immediately and then try everything in %PATH%. So you need to find files that have "Path not found" or "Name not found" AND NOT have "Success" later on.

The process is a bit hard, but I wrote a tool called ProcMon Log Analyzer that does it for you. Just save a Process Monitor log as XML and pass it to the tool. It will tell you the names of DLLs which are missing.

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222