CLI/C++ CodeDom parser error "Unknown type", designer won't appear - c++-cli

I have an old project made in Visual studio 2015 and I want to reopen it in Visual studio 2017. The project contains several forms but none of them will open without giving the following error:
C++ CodeDOM parser error: Line: 104, Column: 21 --- Unknown type ''. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.
The mentioned line is: this->components = (gcnew System::ComponentModel::Container());
As far as I can remember I never changed a thing in the InitializeComponent part.
If needed I can copy a full header file, into the question.
How can I solve this issue?

I once and still see this issue often where it says Unknown Type: '' with a blank type.
After a lot of hits and tries, I finally deleted everything inside .vs folder and it started working back.

Related

String Interpolation gives "Unexpected token" error in VB.NET project

Am working on a legacy solution which includes some VB.NET projects.
Code like this
Throw New InvalidOperationException($"Cannot update {entity.Id} because it does not yet exist.")
yields a red squiggly error "Unexpected token" at the dollar sign. I managed build the code by adding 14 to every build configuration in the relevant .vbproj file, but I am still haunted by these red squigglies. Not only under the $ dollar sign, but also under every End If/End Using/End Sub that follows it, which is considerably annoying.
Am using VS2015 Update 1, and the C# 6 language features, including string interpolation, have always just worked, even within this same solution.
I create File->New Project (implying, an entirely new solution) -> VB.NET Class library, and the code still builds fine but the IDE still gives me the squigglies. Perhaps the problem lies in some obscure machine.config setting? Some VS plugin I need to install?
It looks like the issue is caused by Resharper as of the latest version from today, 23 Dec 2015, and version 10.0.2 Build 104.0.20151218.120627. I've submitted a bug to the JetBrains folks.
I'm not certain how broadly-applicable this problem might be, or if there are any confounding configuration items on my machine, etc.
The issue goes away when I Tools->Options->ReSharper->Suspend Now, and returns when I "Resume Now" ReSharper.

vbc.exe exited with code -2146232797

I am moving a solution with multiple projects to VS 2015. The base project builds just fine in VS 2013. But when I try to build in VS 2015 I get the error below.
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.VisualBasic.Core.targets(56,5): error MSB6006: "vbc.exe" exited with code -2146232797.
Need help please
I talked with MS Tech Support. It's a confirmed bug in the VB compiler. They say it will be fixed in the next update.
In the mean time the work around is to install a Nuget package.
Please follow these instructions to install Nuget package.
Open the affected project in Visual Studio
Open the Package Manager Console (Tools -> NuGet Package Manager ->
Package Manager Console)
Run:
Install-package Microsoft.Net.Compilers -version 1.1.1
I had a large solution that was failing to build after updating to VS 2015 Update 1 RTM. In my case, there were a number of warnings of
Namespace or type specified in the Imports '<import name>' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
that occurred right before "vbc.exe" crashed. Once I removed those extra, unnecessary Imports, the solution build correctly.
This issue is resolved in the latest Visual Studio 2015 servicing update. The relevant download is KB 3110221 which is discussed in this KB article.
In my case, I found that an import was causing the issue. Specifically, after trying a lot of other suggestions, removing the Microsoft.Office.Interop.Excel import from a file, finally got my project to built.
I had the same issue after installing Update 1 to VS 2015.
I've download Microsoft.Net.Compilers NuGet package as Brien King suggested in his answer. This fixed the issue for one project. And then:
"c:\Program Files (x86)\MSBuild\14.0\Bin\vbc.exe" had version 1.1.0.51109
...userprofile.nuget\packages\Microsoft.Net.Compilers\1.1.1\tools\vbc.exe had higher version 1.1.0.51202
So I've copied entire "1.1.1\tools" directory into "14.0\Bin" directory and overrided 27 existing files.
This fixed it for all projects. Remember to create backup before you do this.
After trying both Microsoft.Net.Compilers -version 1.1.1 and KB3110221, my solution was still failing to compile with the same error. Only later I noticed that the error was accompanied by a warning which was letting me know that one of the libraries referenced by the solution was compiled against .NET Framework 4.5.2 while my solution was compiling against .NET Framework 4.5. I recompiled the said library against .NET Framework 4.5 and the solution compiled fine.
Now that my issue was solved after trying three fixes, I can't tell whether the last one alone would have done, but I hope it'll be of help.
I fixed the issue by opening all my .vb files are removing extra imports. Do this for all files and then rebuild. This should work.
I started getting this immediately upon installing vs2015 due to a licensing disagreement w/ MS , which I lost. :-(
Freshly back to work, i encounter this issue.
I tried doing the NUGET suggested by Brien King. Problem persisted.
I tried doing the KN suggested by Teodor Constantinescu. Problem persisted.
I tried a new trivial web app and things were fine, so I did not uninstall vs2013 or vs2015.
I chose to back up my project (3 times, once on a usb stick i put in the other room) and delete groups of files and compile after each group was pulled out.
Ultimately, when I got close to the end (nearly an empty project) it compiled.
By adding groups of files back, I identified the single file that causes this issue. I can recreate the issue by uncommenting a single line.
Further commenting out code, I isolated the problem to 4 lines of code. Beautiful.
Explanation is this...
I have 2 web references that reference ssrs
THese are currently defined in my project as
SSRS_reportservice2010
and SSRS_ReportExecution2005
I struggled getting these to work, so over time i had different names as i deleted and readded the web references. (Padawan)
For whatever reason, a file that was EXCLUDED, got INCLUDED today (2013--> 2015 issue, or greg mouse farting issue? we will never know)
In that (mistakenly included) file, there was a pair of old references
'1 Imports SSRS_ReportingService2010
'2 Imports SSRS = SSRS_ReportingService2010
'3 Imports SSRS_ReportExecution
'4 Imports SSRS_E = SSRS_ReportExecution
Line 1 used to reference the WS now named in my app as SSRS_reportservice2010
You can unComment that and things compile and run. Note that you do get a warning that you are referencing an empty namespace.
Line 2 is of course an alias to the long name, because I am an extremely lazy typer, plus I insist my code be readable and long names stink IMHO.
Line 2, if uncommented , cause vbc error -2146232797
Note that uncommenting 2 , or 1 & 2 cause the error. Its something about the bad alias that causes compiler upchuck.
Repeat the above discussion with lines 3 and 4 which have to do with the webservice currenlty named SSRS_ReportExecution2005
So there you have it.
This took me 8 hours to debug. hope it helps someone.
Many of the other posts, comments, etc also mention Import/Using Statements. The root bug probably lies somewhere in there.... (yes, this is a bug in the compiler)
PS - one thing that was interesting is that the offending file's name started w/ a W so was one of the first to come out.
Nothing improved when I took that file out of the project all together.
I can not explain why the app did not compile as soon as I took the offending file out.
I can offer that I took the webservices out very late in the process, I just didnt think they were the issue.
It baffles me that the file could be gone and I was still getting the issue when I can now simply comment out 4 lines and things work perfectly.
Apologies for the second answer, but this one is much simpler.
I got the error again in a different project 8 days after last time.
This time, I started the day by giving a better name to a class.
I had a class named conversionFactors and I renamed that class to constants to better represent what the class held.
Immediately got the error
vbc.exe" exited with code -2146232797. SizingEngine
tracked it down to this line. I should have used the rename utility. yes. No argument. The compiler should also be more robust. Tsk tsk Microsoft.
Imports cf = SizingEngine.conversionFactors
so steps to reproduce
1. create a new project
2. create a class named Foo
3. create a class named Bar
in Bar, add the following line
imports bar_ = project1.NoClassByThisNameExists
click f5
listen for pac man wilting sound
ps - VS does not report any updates ready for download today. Im sure this will get fixed at some point.
I've just had this same issue. Mine was caused by having a class that had an event inside. I'd referenced this in another class as a shared property. The shared property was causing the compiler to fail. I removed the "shared" declaration and it compiles fine now
I encountered this error when I had a post build event that was throwing an error.
There was no indication this was the problem, just the -2146232797 error.
So check this in the property pages of the project. Go to Compile -> Build Events ... and check the Post-build event command line field. I suppose this might happen with a Pre-build event so check that as well.
The problem may be related with some utilized function in .NET Framework. Try to change the project framework to 4.0 and see if the problem persists.

Ambiguity issue with Vb.Net and MySql Connector

I'm running into a weird issue with a VB.Net project using the MySql ADO.Net connector. I have the following code:
Dim param As New MySqlParameter("#val29", MySqlDbType.DateTime)
And I'm getting the following error message:
Ambiguous invocation:
Public Enum member Datetime As MySqlDbType (in Enum MySqlDbType)
Public Enum member DateTime As MySqlDbType (in Enum MySqlDbType)
match
The difference between them, if you notice, is that DateTime is in a different case then Datetime. Since this is VB.Net and VB is case-insensitive, I'm not sure why I'm getting this error.
Interestingly enough, I opened Object Browser in Visual Studio 2013 and, as you can see from the image below, there does seem to be two definitions of DateTime:
.
Thinking maybe there was an issue with the DLL, I went to their website and downloaded the source code and rolled my own DLL. Same issue. I couldn't seem to find anything on the Internet about it, except for this page, which describes my issue exactly, except it seems to be due to a specific bug in Visual Studio 2015. I'm using Visual Studio 2013. That almost makes me think a Windows Update came along that changed the way the VB.Net compiler works. That doesn't make any sense though because updates are specific to Windows, not Visual Studio. Anyone have any ideas?

vb.net compile error 'abc' is ambiguous in the namespace 'xyz'

I have a VB.Net solution that another developer created and I'm trying to compile it on our build machine (it compiles on their machine) but with one of the projects I get an error saying something along the lines of:
Imyinterface is ambiguous in the namespace anamespaceassembly.
I have tried with no success:
examined the references to see any obvious errors
removed and re-added the assembly in question
searched the system for the same dll
attempted to compile the original deve's src (.v the source control version)
examined the assembly with ildasm.exe
I usually code in C# and have not seen this error before (in this form at least), not that it is VB.Net specific but the UI for adding/viewing references is slightly different so I thought maybe VB.Net might do something different with references.
I also tried to compile on another machine, and it compiles ok. So I assume it is something with the build machine but I'm not sure what. Other conflicting assemblies somehow not referenced by the project, is that possible??
Any ideas?
Check your references if you have two versions of the same reference (eg. Microsoft.ReportViewer.Webforms version 10.0.0.0 and Microsoft.ReportViewer.Webforms 8.0.0.0) You will get this error. Delete the oldest and you should be good. I do this to myself all of the time.
There can be a few causes for this error. In VB, you should be aware that more names then you're used to from C# are available without class specification. Also, case does not matter in VB, which can further liken the chances on collisions.
Even in the event that you don't find the actual conflicting issue, you can resolve this in the same way you would in C#: rename it in the Imports statement:
Imports IM = yourAssembly.Imyinterface
Then change the code such that uses of Imyinterface are replace with IM.
NOTE: If the error does not point to a particular line, the conflict may be out of your hand. Normally, a full Clean Solution and Rebuild helps a lot, but occasionally a misbehaving file (i.e., another error) causes this error to popup first without clear source. Try to rollback recent changes to the place where it did work.
You also say it worked on another machine. Chances are that your machine is having a different version of MS Visual Studio or .NET. Check and compare the exact versions.
I was facing same issue. I upgraded my application from vb6 to vb.net and when i change the build configuration from DEBUG to RELEASE then i got AMBIGUOUS errors.
I found dulicate references folder in solution Explorer. I removed those duplicate referecnces and Build sucessfully. I Hope it may help others.
Thanks for the responses! I tried each but still was having issues.
One point of info I left out of the original question was that the VB.net projects are upgrades from VB6 projects. At the time I did not think that was relevant.
After investigating further the build machine was used to build the VB6 projects also. So I ran 'reg32 /u' on the vb6 dlls and that seemed to fix the VB.net issue.
Not exactly sure why this fixed it since I was not referencing the VB6 dlls, I'm guessing something to do with ambiguous entries in the registry confusing the vb.net project.

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