I'm working on a project started in VB9 (VS 2008) and now I've migrated to VS2010 (VB10) but on the production server the IDE is still VS 2008. On my developement enviroment the code compiles fine, but sometimes, - let's say - I forget an _ at the end of the line which causes the VB9 compiler to throw an error.
So the question is, how could I build a project with the VS 2010 IDE but VB9 compiler? Or to force the VB10 compiler into VB9 mode?
Unfortunately no there is not a way to accomplish this. When compiling in Visual Studio you aren't actually using the command line compiler. Instead you use the inproc hosted compiler (true for both VB.Net and C#). This compiler, while capable of outputting completely valid IL for down targeted platforms, is the version tied to Visual Studio (in this case 10.0).
There is no general way to shell out to a different version of the compiler or to the command line and get the behavior you're looking for.
What you can do though is set the language version of the compiler to be 9. This will issue warnings for a subset of parse level constructs which are not supported in VB9. This cannot be done from the IDE but can by editing the project file directly and inserting the following
<PropertyGroup>
<LangVersion>9</LangVersion>
</PropertyGroup>
Original Answer: Valid for targeting 3.5 but not this question
What you want to do is have your VB project target the 3.5 framework. This will cause the compiler to issue warnings on items that are not valid like _'s.
This can be done from the project properties page.
Right Click on the project and select properties
Go to the compile tab
Set the target to 3.5
Related
I recently upgraded from Visual Studio 2012 to 2017 (updated to version 15.3.5) and have some issues with the IDE.
In a certain project, I don't get error underlining.
and in the Error List pane, "Build Only" actually shows more information than "Build + IntelliSense"
Also, with "Build + IntelliSense" selected, I can only see the compiler error in the Output window. Here is the error list after a failed build
but the output window has this:
3>------ Build started: Project: ..., Configuration: Debug Any CPU ------
3>C:\Checkout...\MainForm.vb(454,27): error BC30311: Value of type 'Module1.aClass' cannot be converted to 'Module1.bClass'.
This doesn't happen on all projects. I made a new project to see if I could reproduce, and I can't. Here is a new project with the same code, where the error is underlined in code and "Build + IntelliSense" works.
I have even sorted the xml in the vbproj files and "diffed" the offending project vs the new project, and there is no obvious difference which would cause this. Both reference the same compiler. Both projects target .Net 4.6.2 and are set to compile for x86 only. The offending project references a few other projects (C# and VB.Net) plus a third party dll and a nuget package. Aside from these differences there is nothing else.
Other projects (C# and VB.Net) in the offending project's solution work fine.
I have seen similar issues talked about online but no fixes have worked for me. I have tried the "Repair" option in the installer. I then uninstalled Visual Studio and reinstalled.
Update:
Changing the target framework seems to have some effect. A project with this behavior was targeting 4.6.2 and showing no errors, and when it was changed to 4.7, it showed a compile error. Then changing back to 4.5 it showed an error. Then changing back to 4.6.2 it showed no errors. Repeating the process proved to be non repeatable. 4.7, 4.5, 4.6, 4.6.2 - whatever, now all show no errors.
It's also important to link this Microsoft page https://developercommunity.visualstudio.com/content/problem/7759/no-errors-displayed-in-the-error-list.html as many other people seem to have a similar issue.
I have solved the problem, at least in my solution.
I was playing around with project references, and found that when a particular project was not referenced by another project, I got error underlining. I went through a process of changing framework version targets until something worked.
All my projects had previously been targeting .NET 4.6.2. By targeting 4.7 on all the projects, I now get proper error underlining and reporting in the Error window.
I'm not sure if this is a solution for everyone and it will take some additional work on my end to deploy my project to production but I can accept this.
I guess this is related to targeting 4.6.2 using Visual Studio 2012 and upgrading to 2017. Maybe something was not set properly if/when the projects were upgraded.
I have to continue a program witch have been coded with Visual Studio and the framework .NET framework 4 but the thing is : I have a macbook.
After many researches I have found that by using Mono it was possible to code in vb.net with a mac. However, the project is working on Windows computer but I get this warning:
"warning MSB3256: No assemblies were read in from the redist lists. A TargetFramework profile exclusion list could not be generated."
and this error:
"error MSB6006: "vbnc.exe" exited with code 1"
So I'm guessing that he doesn't recognize that mono should replace .NET framework. I am executing the code with MSbuild, maybe that is the issue?
Unfortunately you are stuck.
Microsoft would like to bring C#/VB and .NET Core to Mac via Visual Studio for Mac, so you should not attempt to bring any .NET Framework projects to Mac via Mono any more.
This warning is more critical to VB developers, as Mono's VB support (vbnc.exe is Mono VB compiler) is experimental and does not support all VB latest features.
However, for .NET Core development, VB is also not yet ready to be used, and should be available in a few months when Microsoft ships .NET Core 2.0.
You can definitely play with VB by using .NET Core 2.0 Preview build,
https://www.infoq.com/news/2017/05/netcore2preview
But then you cannot use VS for Mac, and have to use an editor such as Visual Studio Code.
For some reason, Mono uses vbnc by default although there is a Roslyn-based VB compiler built-in to Mono, vbc. Interestingly, vbnc is even not being installed with mono-devel package and it still being used by default.
If you installed vbnc and started to get this message:
"error MSB6006: "vbnc.exe" exited with code 1"
you need to instruct Mono to use vbc instead and your code will build. The most reliable way to do it is to set it per project, by adding the following XML to your vbproj file:
<PropertyGroup>
<VbcToolExe>vbc</VbcToolExe>
</PropertyGroup>
The code should be placed inside the root <Project> tag.
I have recently installed VS2015. Yay! \o/
However, one of my C++/CLI projects showed this message when upgrading from VS2013:
The following project(s) uses an earlier version of the Visual C++ compiler and libraries. The project(s) will be upgraded to use the Microsoft Visual Studio 2015 compiler and libraries. Any managed or native code project(s) using C++/CLI extensions will be automatically upgraded to target .NET Framework 4.5.2. Note: If you do not upgrade the project(s), building your project(s) will require the corresponding version of Visual Studio to be installed.
I ok'd the warning, but now code which compiled previously in VS2013 no longer compiles, for instance:
void WritePixels(array<unsigned int> ^ rgbaData);
has the error
'std::array': too few template arguments
'^': cannot use this indirection on type 'std::array'
Also the project properties do not allow me to switch target .NET framework version (it is grayed out).
Is it possible for C++/CLI projects to target .NET 4.0 using Visual Studio 2015? Are there any syntax changes in C++/CLI since Visual Studio 2013 that I need to know about?
Just an update for posterities sake.
I solved this by workaround, by not using C++/CLI at all, but using the amazing, adaptable SWIG Platform Invoke Generator library.
No C++/CLI = no issues with .NET Framework versions, no issues with x64/86 bit and .NET Any CPU.
Problem Solved ...
I have no problem building my VB project in both VS 2010 and 2012 againt .NET 2.0.
However, the MSBuild refuses to build it because it does not like one VB language feature introduced in VS 2010 (it is "implicit line continuation" to be more specific).
I tried the following parameters for MSBuild (from .NET 3.5):
/p:TargetFrameworkVersion=2.0
/toolsversion:3.5
This does not build as the VB feature I use have been introduced in 4.0 tools.
So I changed toolsversion to 4.0 (and using MSBuild from .NET 4.0):
/p:TargetFrameworkVersion=2.0
/toolsversion:4.0
And now MSBuild complains about another thing:
C:\Users\Libor\AppData\Local\Temp\.NETFramework,Version=2.0.AssemblyAttributes.vb(6,24):
error BC30002: Type 'System.Runtime.Versioning.TargetFrameworkAttribute' is not defined.
[project.vbproj]
The only solution now for me is to open my project in VS 2008 and manually correct the code so it is compatible with all tools. But I hope MSBuild can be configured so it builds properly, as VS can build the project against .NET 2.0, too.
Similar question and answer here. They key is going to be:
msbuild YourSolution.sln /tv:4.0 /p:TargetFrameworkVersion=v2.0
I wrote a program in C++ using Visual Studio 2010
But when I run it on some computers with WinXP it says
"Cannot start because MSVCP100.dll wasn't found"
How do I prevent such dependencies on dlls that do not come with windows?
Thank you.
you cannot prevent this dependency, as it's the core runtime library of Visual C++. Instead, include the Visual C++ 2010 Redistributable package with your application (usually a separate link is enough since most people have it installed already)
However, if in fact your program cannot start because a dll with D at the end such as MSVCP100D.dll then you need to build your program in release mode, which by default switches the run time to a non-debug version. You need to be careful to nut out any other included static and dynamic libraries you're including in your project to make sure all debug or all release versions match for your builds.
If you are having trouble finding which sub-projects are referencing the debug versions, you can download and run depends.exe and browse through the exe file to see.
Sorry for the late respones, but yes you can prevent this dependency, just go to solution property of yopur project, go to C/C++ > Code Generator and in Runtime Library change it from MDd to MTd, will include statically the dependent libraries, and not in run time, like this avoid Run time errors while try to run the Dll.