VB.NET 2010 Conversion Errors - vb.net

I'm trying to convert a VB.NET 2005 I inherited to 2010. Right now, the majority of the errors I get during building are: Sub XXX or Property XXX "has multiple definitions with identical signatures". They're all in the same file called AssetsReport.Designer.vb. However, they aren't all exact copies. They will change a little and they are in different classes.
I've worked with ASP.NET, but that was written from scratch. I'm at a bit of a loss on how to proceed here.
The file in question is too large to post here, but you can download it here if you want to look at it.
Thanks

The clue is in the header of the code you posted:
This code was generated by a tool.
You need to recreate the dataset in Visual Studio
have a look at this article on how to do this

Related

Recover files overwritten by generated code

I have a Winforms project that had a amongst others, 7 forms that I blindly named them with the same name that I named tables in my SQL server. Now I was trying to experiment with Entity Frameworks Data Model and visual studio generated classes for the tables in Database. For these 7 forms that class names were identical visual studio deleted all the code that I had in the forms. Is there any way to recover my old code.
I have no usable backup!
I am sorry to say, but unless you have any backup there is no way to recover that files directly.
You could use ILSpy (or one of the other options in this blog article) to disassemble the assembly you have once compiled. You will have at least something like what you had. (You will lose comments and other stuff)
Maybe slightly off-topic, but when you are lucky, you might find your files back with some disk recovery tools like GetDataBack from the company Runtime. I use it a lot myself.

Changing VB.NET code programmatically

I want to open an existing VB class file, add a few properties and close it again.
Simple enough, I thought: Take the CodeDom, a VBCodeProvider, parse the code (using the Parse-method), then identify the location where I want my stuff added (doubtless using some nifty LINQ expressions), add a bit of code and then have it generated and here we go.
Now I see that Microsoft apparently added the Parse method only for the fun of it but never implemented it.
What's the story here? Can I only generate code from scratch? Is it not possible to load existing code?
Does anyone know of any solutions?
You say "class files" and then you say "parse". I think you meant "parse and modify".
Our DMS Software Reengineering Toolkit with its Visual Basic Front End can do what you need on VB.net source code files.
DMS provides general parsing, AST-building, generic analysis and AST transformations, and is able to regenerate source text in compilable form. The Visual Basic Front End enables DMS to process VB.net, VBScript or VB6 and carry out any of these activities.
DMS's Source-to-Source transformations can be used to make changes using "if-you-see-this, replace-it-by-that" patterns.

Is there a Cut & Paste as New Class File (Macro)?

I'm looking for a free Visual Studio feature, extension or macro. that can help with the following situation.
When I prototype I tend to keep all my classes in one file (bad practice I know, but yeah it a prototype). Then comes the point the where the files is too hard to navigate. So I breakout the classes into separate files inside the project, the folder structure reflecting the namespaces.
To achieve the is;-
1. Add new Folder
2. Add new Class
3. Name class
4. Cut and paste corresponding section into new class file.
For me, Steps 2 through 4 are prime fodder for a new Menu entries.
Cut Class as New Class File
Cut as New Partial Class File.
I've seen this feature in C# but not VB.net.
So does know any how to achieve this for VB.net?
Here's a macro that does what you want in C#... looking at the code it's probably fairly straight forward to modify it to work in VB...
http://plisky.net/main/macros/documentation
Also, I'm pretty sure all the commercial refactoring tools (Resharper, CodeRush, etc.) support this...
Resharper can do this using Move Type to Another File or Namespace
I just stumbled across this and can point you to an updated version of the macro that scrappy kindly linked. Its at http://plisky.net/main/plisy.net-visual-studio-productivity-macros.
If you still want it and wish to test it for VB I can happily make the changes to support VB.net but as I don't use VB I'd need a tester :) As its a while since this post you probably have something working already though.

Spreadsheet from DataTable

In my app, I'm downloading a spreadsheet from FTP, moving the data read from the spreadsheet to a DataTable, and, depending on certain conditions, emailing a new spreadsheet (one that contains certain rows from the 1st spreadsheet).
My problem is creating the spreadsheet that will be mailed. I can't seem to work out how to add the row from the DataTable (originally from the spreadsheet that was downloaded) into the spreadsheet that's going to be mailed.
DS.Tables(0).Rows.Add(ObjSheet.Range(workTable.Rows(i)) - 1)
Is what I've got at the moment, but it's not working. workTable is the DataTable where the rows from the spreadsheet were copied to. DS is the DataSet where I'm putting the rows from the specific selection.
I'm pretty sure I can simplify the flow of data by eliminating either the DataTable or the DataSet.
To eliminate any confusion, I'm using VB2005 - Wish I could use 2008 for this, LINQ simplifies so much...
SpreadsheetGear for .NET can help you do this.
See the live ASP.NET (C# & VB) "Excel to Datagrid" samples here. There are more samples - some of which might prove useful - here.
Disclaimer: I own SpreadsheetGear LLC
One of the answers may be to not program with office - if you can use the Office 2007 file formats (and given the existence of the Office Compatability pack there's no fundamental reason why you shouldn't although there may be issues within a specific environment) then you can use .NET code, System.IO.Packaging and the Open XML Format SDK 1.0 - that's .NET 3.0 which is just libraries and therefore useable from VS2005.
More pragmatically, don't be so keen (at least in the first instance) to do away with the intermediate steps - something I need to remind myself at regular intervals.
If you start with the following:
1) Load the data from the source
2) Process the data from the source
3) Write the result out to the destination
Then you'll be able to demonstrate at steps 1 and 2 that you have what you want, and step 3 becomes more manageable in that you're just trying to move known data from app to file.
Hmm, that's more "thoughts" than "answer" - but I hope it helps.

Is there a utility to create VB.NET classes from an XSD file?

Is there a utility out there that will create VB.NET classes from a Dataset.xsd file? And I don't mean like the XSD.exe utility does - all that does is convert the XML of an XSD file into classes in a .vb - it doesn't append any "extended" functionality.
I'm basically looking for something that will generate the beginnings of a business layer from the XSD file. Like creating a partial class for each datatable, then create a property for each of the datatable's columns as the right datatype and finally the basically CRUD methods as well.
This is something I have to do manually over and over again for each project. (I do lots of little projects and use VistaDB so I can't use Linq-To-SQL - wish I could)
I think that xsd.exe will do what you need it to. Here's and example to convert purchaseorder.xsd to a vb class in the Purchasing namespace:
xsd.exe -c -l:vb -n:Purchasing purchaseorder.xsd
Type xsd.exe /? from a visual studio command prompt to get all of the options.
You can find more info here.
Try taking a look at T4 and Code Generation tools in Visual Studio. It's like "writing code that writes code", and it's incredibly powerful.
A great video, really an "aha experience" for me
http://www.pnpguidance.net/Screencast/T4TemplatesVisualStudioCodeGenerationScreencast.aspx
MSDN:
http://msdn.microsoft.com/en-us/library/bb126445.aspx
Rob Conery has written an intro:
http://blog.wekeroad.com/blog/make-visual-studio-generate-your-repository/
... and so did Scott Hanselman:
http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx
I understand it's probably not exactly what you're hoping for, but when you want more flexibility and NOT having to write the same code over and over again, it really sounds like T4 could be a solution.
You'll write a template, that analyses your XSD file and generates the vb files directly in your project.
I know this doesn't strictly answer the question, but it looks like VistaDB either does, or will soon, have a provider that can be used with Linq to Entities - see here
Liquid studio XML Data Binder looks like it does what you want and has a 30 day trial you can download.