How can we help you today? How can we help you today?

problem with datasets when use reflactor to retrieve project

well hi there



i successfully manage to retrieve my project because my ext hard was accidently deleted

well i couldnt belive my eyes

but there is a problems as my project retrive only *.vb files
so the forms i manage to retrieve it but with datasets i couldnt cause it only give me *.vb files so what should i do
athman
0

Comments

9 comments

  • haleyjason
    Sorry to say that you are going to have do to A LOT of work to recover a Windows Forms application. As far as I know, there isn't a good export utility for Reflector to export Winform applications to source code ... this afterall isn't the purpose of Reflector.

    Some of the things you're going to need to deal with:
    1. converting the .resources files to .resx files
    2. splitting the forms files into 2 partial classes
    3. deal with strange and incorrect named coversions (like with enums)

    It is possible ... but unless you have a lot of complicated layouts that you can't recreate easily - it will be faster to just recreate the forms look and feel and use the .vb files that Reflector exported to copy and paste the functions and subs in your code files.
    haleyjason
    0
  • athman
    well thanks



    the funny thing


    that i manage to retrieve the forms easily
    what i was asking is the datasets as in 2008 the dataset extension is not .vb but .xsd
    athman
    0
  • haleyjason
    Sorry, didn't realize it was only the xsd file you were looking for. I would start with the xsd.exe utility (can use it from a VS.Net command prompt).

    If you know the type in the exe/dll and want an .xsd file generated, you need to use a line like this (where DataSet1 is the name of the type you want to get an .xsd for and WinFormApp.exe is the assembly)

    xsd.exe WinFormApp.exe /type:DataSet1

    That will generate probably a few xsd files, which you should then be able to piece together into a single on the vs designer will be happy with. You'll have to play with a test app to see what the designer requires, then paste in your generated schema/elements where needed.

    Sorry, I don't know of any easier way. Good luck!
    haleyjason
    0
  • athman
    are you kid me

    this is not difficult at all as it going to retrieve my project i am willing to do anything to retrieve and so yeah i do as you say and manage to retrieve
    so now let me ask you something

    is there another tool to retrieve forms
    i mean we use xsd.exe to retrieve dataset what the other tool for retrieving the forms i know that u will say the reflector will do the job but if there is a vs tool it will be better

    then u say
    "That will generate probably a few xsd files, which you should then be able to piece together into a single on the vs designer"

    how can i join them as i end up with two xsd files

    ok and abt the forms as i told u i manage easily to retrieve it by adding the vb files and it recognize it as a form but the was a lot of errors more than 100 error so i say i have to figure out his idea maybe ot will come with less errors

    what was your idea exactly abt the

    "Some of the things you're going to need to deal with:
    1. converting the .resources files to .resx files (how)
    2. splitting the forms files into 2 partial classes (how)
    3. deal with strange and incorrect named coversions (like with enums) I CAN DEAL WITH THIS NO PROBLEM
    "



    thanks again
    [/quote]
    athman
    0
  • haleyjason
    To explain the manual fixes will take sometime and will be easier if I do it on my blog (so i can do images and such).

    I'll let you know when I get a post out there for you. Just a heads up - it isn't going to be an easy process for you and will be somewhat painful ... but better than loosing all your work.
    haleyjason
    0
  • athman
    well no problem if it was painfull nothing is easy in our way to know more new things

    by the way u didnt answer this question

    is there another tool to retrieve forms
    i mean we use xsd.exe to retrieve dataset what the other tool for retrieving the forms i know that u will say the reflector will do the job but if there is a vs tool it will be better

    and dont forget to mention ur blog
    athman
    0
  • haleyjason
    I'll try and edit the FileGenerator addin to do this in the next day or two ... but here is roughly what you need to do for cleaning up the Form files:

    Foreach class inheriting from Form
    Create new file of same name with extension of .resx
    Copy form cs file and rename to new file of same name with extension of .Designer.cs

    Foreach .Designer.cs file
    Add 'partial' to declaration
    Remove contructors
    Remove event handlers
    Change float numbers to have 'F' instead of 'f' (may not be a problem with VB)
    Change AutoScaleMode.Font to System.Windows.Forms.AutoScaleMode.Font

    Foreach original form.cs file
    Add 'partial' to declaration
    Remove control declarations (if instantiated in InitializeComponents())
    Remove IContainer declaration
    Remove Dispose method
    Remove InitializeComponents() method

    I'll have to poke around with the schema generator to see how to restore those files too in the next couple of days.

    This should be enough for you to get your forms compiling.

    Good luck
    haleyjason
    0
  • haleyjason
    I currently have an addin working for the Forms problems, but still working on the dataset problems. However there are still several imports/using statements you may have to work out (minor thing on the scale of it). The designer now works in most cases.

    Email me and i'll send you a link to the addin. I don't want to post the link on this group because it isn't complete yet - but it would help you if you are in a hurry.

    my email is haleyjason [at] hotmail [dot] com
    haleyjason
    0
  • haleyjason
    This weekend I put together some code using Jason Bock's FileGenerator addin for a starting point. Here is a rough listing of what I added to it:

    Foreach class inheriting from Form
    Create new file of same name with extension of .resx
    Copy form cs file and rename to new file of same name with extension of .Designer.cs

    Foreach .Designer.cs file
    Add 'partial' to declaration
    Remove contructors
    Remove event handlers
    Change AutoScaleMode.Font to System.Windows.Forms.AutoScaleMode.Font
    ... others

    Foreach original form.cs file
    Add 'partial' to declaration
    Remove control declarations (if instantiated in InitializeComponents())
    Remove IContainer declaration
    Remove Dispose method
    Remove InitializeComponents() method


    Copy Dataset.cs file and create new .Designer.cs file
    Foreach .Designer.cs file
    Add 'partial' to declaration
    Remove any method the doesn't have [DebuggerNonUserCode]
    Remove any property that doesn't have [DebuggerNonUserCode]
    Remove any field declarations that are not set in InitClass() method

    Foreach dataset .cs file
    Remove any method that has [DebuggerNonUserCode]
    Remove any property that has [DebuggerNonUserCode]
    Remove any field declarations that are set in InitClass() method

    Change VSProject to look like this:
    <None Include="TestWinFormsApplication\TestDbDataSet.xsd">
    <Generator>MSDataSetGenerator</Generator>
    <LastGenOutput>TestDbDataSet.Designer.cs</LastGenOutput>
    <SubType>Designer</SubType>
    </None>

    <Compile Include="TestWinFormsApplication\TestDbDataSet.cs">
    <DependentUpon>TestDbDataSet.xsd</DependentUpon>
    <SubType>Component</SubType>
    </Compile>

    <Compile Include="TestWinFormsApplication\TestDbDataSet.Designer.cs">
    <AutoGen>True</AutoGen>
    <DesignTime>True</DesignTime>
    <DependentUpon>TestDbDataSet.xsd</DependentUpon>
    </Compile>

    Replace '$' with '_' in all files


    Notes:

    - The Addin works best if you choose the second level of the assembly tree (where it shows the complete name ie. TestExample.exe (or .dll) - not the namespace which is the first level).

    - The dataset designer won't have your DataTableAdapters (I couldn't figure out how to reverse these)

    - You might need to add some additional using/imports statements to get it to compile

    - If you use linq from the data tables, you'll probably need to replace the base class of the data table to be System.Data.TypedTableBase<yourrow>

    - The table adapter classes are still in their own cs/vb files - this will save you from having them deleted when the designer regenerates ... since I couldn't figure out the xs:annotation creation in the designer's xsd file.

    The addin in currently at: http://jasonhaley.com/files/FileGenerator.zip ... this is an unauthorized hack of Jason Bock's File Generator - so please do not distribute.

    NOTE: in my testing I mostly used C#, so there could be some unknown VB issues.
    haleyjason
    0

Add comment

Please sign in to leave a comment.