MAW74656
MAW74656

Reputation: 3549

Ways to recover lost VB.net application

I'm trying to recover lost code from a VB.net 2.0 application that I've inherited. I have current working versions, so I've tried using RedGate Reflector and Telerik JustDecompile to recover the code. Both will successfully return code files that are readable and Visual Studio project files, but when I try to run the decompiled program, I get 102 error messages (with both decompilers).

I have working Visual Studio projects from old versions, which run fine, but the structure of the solution and code files is completely different and I'm afraid the program was changed too much since then to trust these old versions.

The only odd assembly that was included is SmartCodeDeveloper 1.0.2986.26049. And I suspect the code was originally written in Visual Studio 2005, as both 2008 and 2012 want to upgrade when the solution is opened.

What else can I do to recover this program? I have the code, but something else is preventing it from running, and I'm at a deadend.

EDIT:

Some of the error messages I'm getting are:
-"End of Statement Expected" or "Statement cannot appear within an event body. End of Event assumed."
-Many are variations on "RemoveHandler" definition missing for object.
-object not declared "It may be inaccessible due to its protection level."

EDIT 2:
Is there any advantage to trying to decompile into C#? Is it possible Reflector may do a better job converting to that? What about different .NET framework versions? I've been doing 2.0, which I believe it was developed on.

Upvotes: 3

Views: 1796

Answers (2)

Lauren
Lauren

Reputation: 333

Reflector will create code that isn't VB code, ie. var++ . You will have to find them and fix them. It will also create many event definitions that won't work. Look for code Like Public Custom Event definitions. Delete the Custom keyword and all the lines following until End Event. Also you will need to figure out what Import statements you need.

Here is an example from Reflector

 Public Custom Event ColumnChanging As DataColumnChangeEventHandler
    AddHandler(ByVal value As DataColumnChangeEventHandler)
        Bid.Trace("<ds.DataTable.add_ColumnChanging|API> %d#" & ChrW(10), Me.ObjectID)
        Me.onColumnChangingDelegate = DirectCast(Delegate.Combine(Me.onColumnChangingDelegate, value), DataColumnChangeEventHandler)
    End AddHandler
    RemoveHandler(ByVal value As DataColumnChangeEventHandler)
        Bid.Trace("<ds.DataTable.remove_ColumnChanging|API> %d#" & ChrW(10), Me.ObjectID)
        Me.onColumnChangingDelegate = DirectCast(Delegate.Remove(Me.onColumnChangingDelegate, value), DataColumnChangeEventHandler)
    End RemoveHandler
End Event

It would be changed to this :

Public Event ColumnChanging As DataColumnChangeEventHandler

Missing References will cause many errors also.

Upvotes: 1

Zeddy
Zeddy

Reputation: 2089

I've seen this same problem once before. Described by another member. Its really simple to correct. The reason you have these 100+ errors is usually because of something trivial... Like an unterminated strig for example. Yet a simple error pushes everything else out of sync so you get more errors displayed than the actual amount of REAL errors, because of the ladder effect that ocurs due to the first error (cause of issue).

The BEST way to deal with it is as follows....

1 - Open your solution
2 - Close all document windows - so no solution documents are displayed
3 - Compile your solution
4 - At this point your errors should be minimised to a much lower amount of errors like maybe 1 to 10 for example.

Try that and let me know how many errors are listed AFTER you have done the above.

Upvotes: 1

Related Questions