Hi,
I’m at last coding in VB.net with the .net Microframework thanks to the hard work of the people at GHI converting libraries over to use .netmf 4.2
There are a couple of gotcha’s I’ve come across so far converting my Tyrannt game over to VB.
Firstly there is a small problem with the Auto-generated code for resouces which I expect will be fixed by the time the release comes out of Beta.
Inside the code-behind Resources.Designer.vb
Namespace TyranntVB Partial Friend Class Resources Private Shared manager As System.Resources.ResourceManager Friend Shared ReadOnly Property ResourceManager() As System.Resources.ResourceManager Get If (Resources.manager Is Nothing) Then Resources.manager = New System.Resources.ResourceManager("TyranntVB.Resources", GetType(Resources).Assembly) End If Return Resources.manager End Get End Property
You’ll notice there is a Namespace being used. This is what is required in C# but not in Visual Basic. If you remove the Namespace commands
Partial Friend Class Resources Private Shared manager As System.Resources.ResourceManager Friend Shared ReadOnly Property ResourceManager() As System.Resources.ResourceManager Get If (Resources.manager Is Nothing) Then Resources.manager = New System.Resources.ResourceManager("TyranntVB.Resources", GetType(Resources).Assembly) End If Return Resources.manager End Get End Property
Code like this
Resources.GetFont(Resources.FontResources.tyrannt)
Will compile successfully.
Secondly, by default, the project will not know about constants like vbCr and vbLf. I used “\n” quite a bit inside the C# code and when I came to use vbLf the equivalent in VB.net, it caused a compilation error. This is simple to fix. Add the following Imports statement to the top of your code and away you go.
Imports Microsoft.VisualBasic.Constants
I’ll hopefully post again when I have the code ported and running on the Spider.
Hi vbmagic, its James Scott from the .NET Gadgeteer team at Microsoft here.
Its great to hear you’re using Gadgeteer/NETMF 4.2’s Visual Basic support – we built this in to reach people like you who want to build hardware using the nice features of VS and managed code but prefer VB to C#.
Thanks for pointing out these two issues with the VB template that ships with GadgeteerCore, I’ve fixed both in our internal repository, and they’ll show up in the next release (date TBD). FYI, the fix for the namespace issue was to put it back into Program.vb, rather than stop the resources code generator from inserting it.
Until the next release, your suggested workarounds are really useful, thanks.
Just FYI, any Gadgeteer feature requests/bug reports can be filed at http://gadgeteer.codeplex.com/ too.
Comment by James Scott — 2012/08/30 @ 2:00 pm
[…] https://blog.vbmagic.net/2012/06/24/net-micro-framework-and-vb-net-on-fez-spider-a-couple-of-gotchas/ […]
Pingback by Using VB ‘Resources’ on NetMF « Steven Johnston — 2012/11/13 @ 5:09 pm