At work, I was the first to upgrade my machine to Windows 10 and Visual Studio 2015. Opening our application’s solution, I started resolving little errors here and there. One problem was not so simple and had a very obscure solution.
We have a small collection of Silverlight apps written in VB.NET. With the upgrade to Visual Studio 2015, they would not compile. The errors returned were:
Microsoft (R) Visual Basic Compiler version 18.104.22.168618
Copyright (C) Microsoft Corporation. All rights reserved.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.ApplicationServices.ApplicationBase’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.Devices.Computer’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.MyServices.Internal.ContextValue’ is not defined.
vbc : error BC30002: Type ‘Global.Microsoft.VisualBasic.ApplicationServices.User’ is not defined.
vbc : error BC30002: Type ‘Global.System.ComponentModel.Design.HelpKeyword’ is not defined.
In the course of troubleshooting, I excluded everything from the project except the AssemblyInfo file and I still got the errors. So I created a new Silverlight project, which built fine, and compared the Detailed compiler output. The compiler line in the 2015-created project had a slightly different parameter (difference highlighted):
This clicked with me from my experience with building Silverlight apps for the Zune, where you had to exclude the My namespace that is created with VB.NET applications. Look at the assemblies being referenced. ApplicationServices.ApplicationBase (My.Application), Devices.Computer (My.Computer), ApplicationServices.User (My.User).
So, how do you get this extra compile setting? It’s in the .vbproj – there’s no UI for it. You’ll have to edit the vbproj file directly.
Unload the Silverlight project, right-click it, and choose Edit .vbproj. Look for the node <NoStdLib>true</NoStdLib> (there will be one per project configuration) and after it, add: <MyType>Empty</MyType>. This node is included with new Silverlight projects in VS2015.
Save and reload the project and the MyType flag will be included in the vbc command line, which will allow the Silverlight application to compile.
Of course, a lot of people will probably create a new Silverlight project and move all their code into it and be just as successful. But, if you don’t want that hassle, or if you just want to know why (as I did), there’s the solution.