Visual Studio marks data type as syntax error? - vb.net

Well, I've opened a solution I worked on previously (without any errors), and suddenly VB.NET finds "errors" in data types. What could possibly cause this? The code compiled before, without any syntax errors. A review by a few colleagues also didn't point out any other errors in the code. It also breaks on er in Integer, suddenly ignores End While even though they match and a whole bunch of other non-errors. I've tried re-formatting the code, reinstalling Visual Studio etc. Something in the code is causing this, but I have no idea how this is even possible.
Example 1
Example 2

Related

VB.Net Website project returning errors which are not errors when I try to build it in vs2019

I made some changes to a VB.Net website project in Visual Studio 2019, and then I merged them into the UAT project in TFS, so that they can be published to our UAT site. When I try to build the project the Error List contains one item stating:
Maximum number of errors has been exceeded.
When I look at the Output tab I can see a long list of errors, but when I investigate them they are not errors at all. Some of the messages indicate syntax errors, but when I view the code nothing is highlighted and it all looks fine. Some of them say that a variable has not been declared, but it has. I also get Character is not valid errors - but again nothing is highlighted.
I should say that none of these errors is in any of the files I have been working on so they should be the same as the code which works fine on the UAT site. I already tried deleting the .vs folder and removing related folders from the Temporary ASP.Net Files folder, which fixed some issues I was having earlier, but not these errors.
I don't want to rant, but I feel like if Microsoft had a better testing regime there would be less of these sorts of issues and developers wouldn't need to waste so much time trying to work around their mistakes. I'm completely stuck at the moment so any suggestions would be gratefully received.
I wish I could say I know how to fix this but I don't. All I know is after a mixture of visual studio restarts, failed publishes, and a couple of fixed references the project now compiles and even publishes.
That would've been a lot easier and less stressful if visual studio provided more accurate error messages

Visual Studio replaces DataTable with TypedTableBase

Using Visual Studio 2008 in order to compile for Windows Mobile 6 devices, I get an issue where changing anything involved in a DataSet results in the error genasm.exe(1): error There was an error finalizing type. GenericArguments[0], 'Mobile_Verification.ScanData+TRANSRow', on 'System.Data.TypedTableBase1[T] violates the constraint of type parameter 'T'. on the next build.
Selecting this error takes me to Microsoft.CompactFramework.Common.Targets, where there is an error on
<Target
Name="BuildAsmmeta"
Condition="'#(None)'!=''">
<BuildAsmmeta <!-- This is where the error is -->
.....(contents)
>
stating The element 'Target' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element 'BuildAsmmeta' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements expected: 'Task, PropertyGroup, ItemGroup, OnError in namespace http://schemas.microsoft.com/developer/msbuild/2003'. Kind of strange for automatically generated code.
On comparing source controlled code to the new code, I find that Visual Studio has changed all instances of
Inherits Global.System.Data.DataTable
Implements Global.System.Collections.IEnumerable
to
Inherits Global.System.Data.TypedTableBase(Of MyRowName)
Now, in the past, when this has popped up, I've been able to just revert my changes so everything is happy. Now, however, I have some changes of substance to make to the dataset, so I would really like to make this not be an issue anymore.
Searching for solutions, however only seems to give fixes going in the opposite direction: Visual Studio forcing a DataSet when a TypedTableBase is expected. Digging in seems to suggest that the issue might have been introduced to our code when we upgraded from .NET CF 2.0 to 3.5. Apparently TypedTableBase is just the way to do things now, and Visual Studio is enforcing the new paradigm. The fixes suggested here do the exact opposite of what I need.
All well and good, except something is apparently broken in the translation. So now I'm left with three options:
Keep manually fixing it every time I need to change the DataSet
Prevent Visual Studio from automatically changing my DataTables to TypedTableBases.
Figure out what is broken in the new TypedTableBase implementation, and fix that. Specifically, since the error is only being thrown in Common.Targets, and there isn't anything showing in my code, what part of my code is it exactly that the auto-generated code is having a problem with, and how do I get it working?
I would try to find any more details to give, but my boss is telling me it's time to get out of the office. If there is anything else that might shed some light, let me know and I can look for it tomorrow.
Thank you.

Encountered Strange Error: " & ErrorName

New to VisualStudio 2015, but not to programming. Have searched both Google and here for a lead on this, but considering the available search terms, I might not immediately uncover them.
I was looking into porting an old VB6 (200k+ LoC) to VB.Net in VS2015. Mostly just poking around to determine viability. Using a project converter, and have resolved most of the initial errors, and am familiar with how the Error List works.
However, it is throwing a new one at me. It now only has two lines of error, both showing the same thing. They both say:
" & ErrorName
That's a Quote, Ampersand, and ErrorName. That's all that show up on the error list line. No file. No line number. Double click on them does nothing.
I thought perhaps the project was corrupted, so I completely re-created it, adding all the modules, forms, classes, etc again, and it found a lot more errors to fix, which I fixed, and now these two lines show up again.
Does anyone have any indication where this is coming from, or, better yet, how to fix?
I've seen VB programmers report this misbehavior before, never with a good lead to explain the problem. It is specific to VS2015, the Roslyn integration caused many issues. In general a very buggy release, be sure to apply all available Updates, currently up to Update 3. If you have a license that includes an MSDN subscription then I recommend you install VS2012, the last "good" version of VS that was not yet affected by Microsoft's new focus on agile development.
I think the underlying issue is caused by the IDE simply not parsing the compiler error message correctly. Probably having to do with the statement with the error getting quoted in the message. Getting only part of the statement text and it fumbling quotes is a pretty good hint that this is where it went wrong.
So look at the actual output of the compiler, decent odds you'll now see the full error text. Use Tools > Options > Project and Solutions > Build and Run. Change the "MSBuild output build output verbosity" setting to Normal. After the failed build, use View > Output to see the compiler output. You'll probably have a lot of messages, consider copy/pasting the content.

Visual Studio 2013 Compilation Error - Code not detected properly

Having a very odd issue with Visual Studio 2013, curious if anyone else is seeing anything similar. I have VS 2013 Ultimate, it seems like once a day, while I'm working with a file, the compiler just suddenly freaks out and doesn't detect my code anymore in my web forms. Take a look at the screenshot below (I just chose a random spot in the middle of the web form), but out of nowhere, VS starts erroring, telling me that variables aren't declared, that method arguments need parenthesis on lines of code that aren't methods, all sorts of whacky stuff.
I assure you, I don't have any broken references, I didn't forget to close an if statement.. nothing like that. All I'm doing it writing some code, and randomly the whole page just starts to error like this. To resolve, all I can do is copy the code contents, delete the page, recreate the page, and paste the contents back into my "new" file... same exact code, only no errors. I wouldn't even worry about doing this if I wasn't doing this at least once a day.
Any help is appreciated, thanks!
Edit: For what it's worth, I found a slightly easier workaround for this issue. If I edit the properties of the class file to "Do not Compile" and then back to "Compile", the IDE is able to read the file just fine...
It looks like this is simply a bug in the Vb.Net Compiler / IDE. I agree it's unlikely to be a bug in your code because you can see that the error squiggles don't line up with places that would represent the errors you are reporting. This is sometimes a sign of an IDE bug
In terms of fixing the problem though you can probably get them to go away by closing and reopening the solution in question. Baring that restarting Visual Studio. I wouldn't resort to deleted / recreating the page.
Long term though you may want to file an issue on connect so the IDE team can try and fix the problem.
http://connect.microsoft.com/VisualStudio

Spurious "User-defined type not defined" error in Microsoft Word VBA

I have a Microsoft Word template with some code and some references, that has been working fine for months but has just started throwing up a spurious "User-defined type not defined" error whenever I open it or try to compile it.
I know it's a spurious error because I haven't made any significant changes to the code. In fact, I've rolled the code back to the last deployed version (which I know works fine) and I still get the error. I've also commented out all the code in the template and I still get the error. I've also removed and re-added all references (same error), and removed all the references and added them back, one by one, until the resultant compile errors are resolved, at which point I'm left with the spurious "User-defined type not defined" error. (I'm going to call this a UDTND error, from now, to avoid driving you all mad.) I think the error started popping up after I rebooted my PC. It only happens with this template, but I don't see how it can be anything to do with this template.
Interestingly, the error is subtly different from a genuine UDTND error in the following ways:
No code is highlighted when the error is displayed.
The dialog is titled "Microsoft Visual Basic", and contains the error message but, unlike a real UDTND error, doesn't contain the text "Compile error:";
It happens when the template is opened, not just when it's compiled (at least, I think that's different from a normal error).
I've tried Googling it but I just get a bazillion results from novice developers asking why they get this error, with responses telling them that they either need to declare the missing type, correct the spelling of the offending variable type, or add a reference to a missing library. I've been banging my head against my screen all afternoon, and that's helped about as much as all the other things I've tried (i.e. not at all). I have a feeling that this is something to do with a messed-up reference, but afaict they're all fine, and I've removed and re-added them, which I would expect to resolve that sort of problem.
Any ideas...?
Your trouble-shooting on References is sound. Once upon a time (and I don't recall the precise error) I was at the same point, and the reference ordering was the key. When you're designating References, you'll notice a "Priority" adjustment feature. Experiment with that and you may solve this.
I have had "User-defined type not defined" problem on several occasions when compiling Microsoft Visual Basic 6 (MSVB6) code that was compiling without a problem earlier. It seems to happen after I have had a long coding session without rebooting the computer. As you can guess, I have been using Microsoft operating systems. I currently am using Windows XP. Rebooting the computer usually fixes the problem as it so often does on Microsoft operating systems.
I have read that fully qualifying declarations also can help, e.g., "Dim oBar as Foo.Bar" instead of "Dim oBar as Bar". I have not tried this approach however.
I had a very similar problem.
My problem appeared (I think) just after I made a Search and Replace that I canceled (Ctrl+Z). There was not highligting of the problem, only the ""User-defined type not defined" error message when I compiled.
I tried:
1) restarting computer
2) changing reference ordering
3) removing functions/procedures, modules one at a time.
Didn't work. My project was written in Excel VBA and here was the solution I found.
THE SOLUTION:
I opened a new Excel file and opened the Visual Basic Editor. I then copied all Forms, Modules, and Class Modules one by one into the new file. I then Copied the Control Objects (3 Commandbuttons) from the old sheet into the new one. Now the new file was identical to the old project - only the ""User-defined type not defined" had gone and problem was solved.
Yea references would be the first step in troubleshooting this problem as already stated, but failing that id start commenting out the code in any event procedures running at start up (my experience is only with Access VBA though)
I had the same problem with Excel 2013.
It started when I did a search and replace on the name of a Custom Class.
I changed the name of the Class after I did the search and replace on all references to it and the spurious error started immediately after that.
I reverted to an earlier version ad confirmed that the problem was not there and then did the same search and replace and re-name and got the exact same behaviour again.
The Custom Class that I changed the name of only had one consumer and it was also a custom class.
I exported, removed and re-loaded the sole consumer class and the problem was fixed.
Check out this link for a Microsoft bug that might be related.
TLDR:
The reference to a package/addin/whatever probably needs to be re-referenced. Check Tools -> References in the Menu.
Also it appears that if you install Microsoft Security Advisory 960715, that certain controls are killed. There are fixes which may or may not work for you. A good article is on this blog:
VSOD Blog