Shop OBEX P1 Docs P2 Docs Learn Events
Calling all vb.net experts - help please! — Parallax Forums

Calling all vb.net experts - help please!

Dr_AculaDr_Acula Posts: 5,484
edited 2013-04-11 23:49 in General Discussion
How would I write and compile a "Hello World" in vb.net?

I've been using Microsoft's Basic since back in the late 1970's, and even right back then it was possible to write a program, run it, and then when it was debugged, run it through a compiler and produce an executable file.

I've followed that through with almost every version of Basic and it has always worked.

Recently I needed to upgrade my PC from XP to Windows 8, mainly because vb.net does not seem to be supported in XP any more. I looked at vb.net version 2012 but this only runs on Windows 8 and Win8 is only on a tiny percentage of computers. So for developing for programs likely to run on the widest number of platforms, I settled on version 2010.

Download the vb.net program on a new Win 8 machine. Open up vb.net as a console application. Write this program, which is about as simple as it gets
Module Module1

    Sub Main()
        Console.WriteLine("hello")
    End Sub

End Module

Hit Ctrl F5 to run and it prints hello on the screen.

Now try to compile this. Compilation is called Publishing now, but I think it is the same thing. But it fails with two errors, as shown in the screenshot.

A search on these errors in Google takes one off on a long search through all sorts of sites. One helpful site said that there is a bug and it depends where the compilation is run from. If you run it from Project/Publish, it will fail, but if you go to the right side panel called Solution Explorer and right click the filename ConsoleApplication1, and then Publish, it will work. However, those sites seemed to be talking about C# and that somewhat promising avenue failed to help.

Another site suggested maybe it was something to do with certificates, but following their suggestions also didn't help.

Do any kind souls on this forum have any experience with compiling files on the latest version of Microsoft Basic?

Or is it finally, after 35 years, time to look at a non-microsoft solution??

I'm working on a multi propeller solution and one problem I've come up against is timing issues with downloading. The GUI version of a vb.net program running xmodem works, but it fails sometimes and I think it is due to the vb.net program having too many timing overheads. Judicious use of Application.doevents to pass control to shelled batch files helps to some extent, but I think it will work better with a "close to the metal" console line application run from a batch file. Of course, such a program is simpler than a GUI and therefore, many other programming languages would also be possible to use. All the program needs to do is read the parameters, open files on the disk, open comms ports, turn the data into xmodem packets and send out the data.

Any help here would be very much appreciated.
1024 x 768 - 97K
«1

Comments

  • ctwardellctwardell Posts: 1,716
    edited 2013-04-04 06:37
    Dr.A,

    It may be a rights issue, try launching Visual Studio as an Administrator. Not sure how you do that on Win8, on Win7 you just right click on the Visual Studio icon and select Run as Administrator.

    C.W.
  • Mike GMike G Posts: 2,702
    edited 2013-04-04 07:24
    You can't (kinda') publish a windows console application. Generally publishing is used for web applications. Just press F5 or Ctrl-F5. Select "Build" to compile.

    Serial port events ride on a secondary thread. You must take care when working with the serial port library.

    Let me know if yo need any help at all...
  • ctwardellctwardell Posts: 1,716
    edited 2013-04-04 07:53
    Mike G wrote: »
    You can't (kinda') publish a windows console application.

    Yes you can, publish creates a ClickOnce deployment for the application.

    C.W.
  • davejamesdavejames Posts: 4,047
    edited 2013-04-04 08:11
    ctwardell wrote: »
    Yes you can, publish creates a ClickOnce deployment for the application.

    C.W.

    ...from my experience with VB2005 and VB2008, the "publish" feature does create a run-able application. I have not used VB2010.
  • Mike GMike G Posts: 2,702
    edited 2013-04-04 09:08
    ctwardell wrote: »
    You can't (kinda') publish a windows console application.

    Yes you can, publish creates a ClickOnce deployment for the application.

    C.W.

    Click Once is used to deploy windows applications from a web server or remote server. That's why I said kinda'. I could be wrong but I do not think Dr_Acula is trying to publish a console app to a web server and install the app to multiple users..
  • davejamesdavejames Posts: 4,047
    edited 2013-04-04 09:19
    ..."click once" does allow for multiple targets of publishing, so yes, web/remote servers were included. The other was as a stand-alone application, which I've done in VB2005/2008. Again, not sure if that's changed in VB2010.
  • ctwardellctwardell Posts: 1,716
    edited 2013-04-04 09:27
    davejames wrote: »
    ..."click once" does allow for multiple targets of publishing, so yes, web/remote servers were included. The other was as a stand-alone application, which I've done in VB2005/2008. Again, not sure if that's changed in VB2010.

    2010 is the same.

    C.W.
  • Mike GMike G Posts: 2,702
    edited 2013-04-04 12:42
    This is how I use Click Once...
    http://msdn.microsoft.com/en-us/library/t71a733d%28v=vs.100%29.aspx

    I'm not really sure where you guys are coming from...
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-04 14:49
    Thanks for all the helpful suggestions. I'm at work now and just a quick test on visual C# 2010 and it all works fine and compiles (publishes?). The IDE for C# and VB are identical. I'm downloading vb.net on the work computer and will test it shortly.
  • jmgjmg Posts: 15,173
    edited 2013-04-04 15:25
    Dr_Acula wrote: »
    Or is it finally, after 35 years, time to look at a non-microsoft solution??

    I'm working on a multi propeller solution and one problem I've come up against is timing issues with downloading. The GUI version of a vb.net program running xmodem works, but it fails sometimes and I think it is due to the vb.net program having too many timing overheads.

    If you do not need GUI Fluff, why not try FreeBasic ?

    http://www.freebasic.net/

    I've used that for some comms stress testing - produces nice small, stand alone EXEs (remember those ?)

    There is also a good Debug development (written in FB)
    http://www.freebasic.net/forum/viewforum.php?f=8
    and the Debug also gives all source, so if you want to learn GUI in FreeBasic, it is a very good example.

    IIRC their Open Com has many handshake options, and experiments showed not all handshake lines are the same...

    here is a paste, and cryptic comment from way back... it can open any supported baud, this tests a skewed 9665
    #IFDEF Baud9665
    If Open Com ("com9:9665,n,8,1,cs100,ds0,bin" For Binary As #1) <> 0 Then 'cs100 senses DB9.Pin8
      Print "Unable to open serial port, or  not Ready"  'ds<>0 Reports if Pin 6 Not RDY
      End
    Else
      Print "com9:9665"
      Br = 9665
    End If
    #EndIf
    ' Waits forever on ds, RX, if DB9.Pin8 is Open.
    ' cs AND ds, gives problems, ds alone is OK, csNNN is also OK
    ' csNNN seems to enable BOTH Pin6 and Pin8 sense. Needs a ds0 to explicit disable Pin6
    ' so looks like it seeds BOTH lines, as default.
    '
    
    
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-04 15:54
    Thanks jmg. Programs like freebasic look interesting. I am ideally looking for something that will run on the most number of platforms (quite simply, so I can share it with the most number of people on this forum!).

    Interestingly, everything works fine on the XP work machine. So maybe it is a Windows 8 issue?

    I've got a Windows 7 machine I can test this on - that might be the next step.

    I suspect this might be the price to be paid for being an early adopter of Windows 8 *grin*.
  • jmgjmg Posts: 15,173
    edited 2013-04-04 16:04
    Dr_Acula wrote: »
    Thanks jmg. Programs like freebasic look interesting. I am ideally looking for something that will run on the most number of platforms (quite simply, so I can share it with the most number of people on this forum!).

    FB claims Microsoft Windows, DOS and Linux. ? - or did you also want MAC support ? ( does vb.net do that ? )
  • davejamesdavejames Posts: 4,047
    edited 2013-04-04 21:54
    Dr. - FYI

    RealStudio...aka "RealBasic":
    http://www.realsoftware.com/

    This package is supposed to provide multi-platform compilation for Windows, Linus, and Mac. I've had people tell me it's the bees knees, and I was seriously looking at it last year. My needs changed and I didn't choose to purchase the product.
  • jmgjmg Posts: 15,173
    edited 2013-04-04 22:02
    davejames wrote: »
    Dr. - FYI

    RealStudio...aka "RealBasic":
    http://www.realsoftware.com/

    This package is supposed to provide multi-platform compilation for Windows, Linus, and Mac. I've had people tell me it's the bees knees, and I was seriously looking at it last year. My needs changed and I didn't choose to purchase the product.

    This looked good last time I checked, but note that the $99 personal copy, does not tick "Deploy on Mac OS X, Windows, Linux"
    - you need to get to $299 before that kicks in.

    I think it also does not create stand alone .exe files.

    ( The Delphi Starter edition, is also windows only )

    Someone who uses a MAC might comment on windows-emulators + comms handling of command line PC apps ?

    If you need something more than FreeBasic, and MAC/OS-X support matters, then best is probably
    http://wiki.lazarus.freepascal.org/Main_Page
    http://lazarus.freepascal.org/index.php
  • Heater.Heater. Posts: 21,230
    edited 2013-04-04 22:55
    Dr A,
    ...quite simply, so I can share it with the most number of people on this forum..
    Do you mean "share" as in people can run it or "share" as in people can hack, modify, contribute to it?

    The former is not very interesting. The latter still seems to be problematic. BASIC is not an attractive proposition, especially at the prices quoted above. There seems to be a dearth of cross platform tool kits anyway in any language.

    C# is an option as the .NET run time is available for Mac and Windows. The resulting program will even run on ARM devices.

    Qt is one of the best cross platform tools (See Simple IDE) but I remember you had issues installing it and C++ may not be your thing.

    You can drive Qt GUIs from Python, a very popular and easy to use language. See PyQt : http://arstechnica.com/information-technology/2009/03/how-to-deploying-pyqt-applications-on-windows-and-mac-os-x/

    Anyone else got suggestions?

    I guess there is Java...
  • Mike GMike G Posts: 2,702
    edited 2013-04-05 06:23
    Dr A,

    I want to clarify... Build in Visual Studio sends the binary output to the bin folder. By default, the bin folder is not visible in the solution explorer. To see the bin folder, select the project and click the "View all files" icon in the menu bar of solution explorer. Open the bin node and find the Debug and Release folders. Expand Debug and you'll see the binaries. Right click on the Debug folder and select "Open folder in windows explorer". Double click your exe to run the console application.

    To create a release version (no debug symbols), select Release in the solution configuration drop down in the Standard tool bar and build. The output is directed to the Release folder.

    Build is invoked when selecting Start Without Debug and/or Start With Debug, F5, ctrl-F5.

    In my opinion, publish means to make public. It's a term used in web development for moving content to a web server. A little history... back in the day, Microsoft classic asp web pages contained script that executed on page request. You see that kind of thing today with PHP. This architecture creates spaghetti code because the same type of code is copied and pasted to many web pages or server side included. Enter COM and COM+ to encapsulate logic - that's another story. Anyway, back in 2002ish Microsoft released .NET 1.1. A completely different beast. An entire web site, excluding the HTML, became a dll. Now a developer could organize and share code across multiple domains. The term publish remained however. Today publish can mean many things in Visual Studio. For example, when I publish a site I also deploy DDL and DML - database stuff.

    So... if ya just wanta' run the Hello World console, open the bin folder and double click the exe. If ya want other to run Hello World, give em' the binaries - or - publish and distribute the installation exe. The later will register the app in Windows.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-05 06:32
    ...or "share" as in people can hack, modify, contribute to it?

    Yes, that is the idea.

    One problem with cutting edge things is coding in several languages at once. eg running three propellers in parallel with Spin code, using a vb.net IDE, with Spin being run through GCC to C++. It gets confusing with things like =, == and :=

    So in an ideal world, all that would be done in one single language. And I guess that has to be C++.

    Many of the problems I had with Qt were related to running a very early version of XP. I'm now got a desk setup with a Win7 and a Win8 machine side by side and things do seem much less problematic.

    Qt or SimpleIDE or Code::blocks or C++ in .net or C# in .net.

    So much seems to point to C++.

    Right now I have xmodem in vb.net on the PC side talking to xmodem in Spin on the propeller. With the spin2cpp translation the xmodem on the propeller side is now in C++. It would be kind of cool to have the same language on the PC and on the propeller.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-05 10:31
    Dr_A,

    It's not a language thing. There are many languages out there. There is no single language to solve all problems.

    However. I have a plan....

    The single most easiest way to make a cross platform GUI now adays is in your WEB browser. No matter if you are Windows or Mac or Linux using Chrome or Firefox or IE the same GUI can work.

    All that it needs is a little "glue" connecting the serial port to your Propeller to your web page.

    That we will do with JavaScript running under Node.js.

    If nobody beats me to it I hope to show a demo soon....
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-05 11:24
    .NET?
    .NOT share
    .NOT cross platform (without mono and who really ever wanted mono?)

    Share?
    Python
    Perl
    C++
    With Qt

    Browser based = good
    JavaScript and Node = good

    Heater? Demo PLEASE!!
  • Heater.Heater. Posts: 21,230
    edited 2013-04-05 12:00
    mindrobots,
    Heater? Demo PLEASE!!

    Oh dear, now I actually have to do something:)
  • jmgjmg Posts: 15,173
    edited 2013-04-05 13:23
    Dr_Acula wrote: »
    Right now I have xmodem in vb.net on the PC side talking to xmodem in Spin on the propeller. With the spin2cpp translation the xmodem on the propeller side is now in C++. It would be kind of cool to have the same language on the PC and on the propeller.

    'the same' is always going to me more notional and semantic, than real, as eventually you need to hit the real world of libraries.
    - but you can aspire to 'similar' or using the same/similar syntax.

    I have found there is some activity on FreeBASIC on the MAC,

    http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/2010-October/012337.html
    http://rpg.hamsterrepublic.com/ohrrpgce/Compiling_in_Mac_OS_X

    and a good list of 'candidates' seems to be here :

    http://stackoverflow.com/questions/4110720/what-is-a-good-basic-compiler-for-mac-osx

    so it may be a combination of Browsers for GUI, and FB (or compact equiv) for command line work, is practical and (moderately) portable.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-05 15:26
    The single most easiest way to make a cross platform GUI now adays is in your WEB browser. No matter if you are Windows or Mac or Linux using Chrome or Firefox or IE the same GUI can work.

    All that it needs is a little "glue" connecting the serial port to your Propeller to your web page.

    That we will do with JavaScript running under Node.js.

    If nobody beats me to it I hope to show a demo soon....

    Yes, please tell us more!

    Ok, I did a bit of research. To send a file from a PC to a Propeller using javascript (or any other language) one would need to

    1) Read some sort of config file with the directory location of the data file to read and the com port to use
    2) Open text file for reading
    3) Read data
    4) Store data locally, in an array or something (can javascript do that?)
    5) Send data out of a serial port
    6) Display status and error messages as required.
    7) Possibly automatically shut down the program at the end

    Well, one thing Javascript should never be able to do is write to files on a computer http://stackoverflow.com/questions/2090747/write-local-file-with-jquery-or-javascript

    If it can do that, what a wonderful platform for malicious virus code. I'm mildly disturbed that in that discussion thread someone said that it is possible. I sincerely hope not.

    Fortunately, I don't think we need to write local files. Just read them.

    Having used this in earnest for half a day, I think I like the idea of using an existing propeller editor as the Spin editor. Proptool or BST. Have three or more spin files open, one for each propeller in a multiprop solution. And have a simple batch file that does the compile/download. If one is editing three spin files at once, just need to remember to save all of them prior to a recompile. It isn't quite as good as having multiprop download as part of the IDE, but given we don't have access to source code for any propeller editor, it probably is the best we are going to get.

    I am intrigued about the idea of GUI in a browser. If you can get it to talk to a serial port that would be very cool!
  • jmgjmg Posts: 15,173
    edited 2013-04-05 15:59
    Dr_Acula wrote: »
    Fortunately, I don't think we need to write local files. Just read them.

    perhaps write to the Clipboard ? There will always be some need to read data into the PC.
  • Mike GMike G Posts: 2,702
    edited 2013-04-05 16:00
    Invoking serial COM from a browser is no different than writing client code. That catch - a device must be attached to the box executing the code and that would probably be a web server. In my mind kinda' defeats the purpose...

    The Spinneret can do this all day and program other Propellers. I posted an example some time ago in the Spinneret forum. I'll try to find it.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-04-05 16:56
    I think the trick is there is a JavaScript client side component that runs in the browser talking to a server side node.js (JavaScript) component that can safely have a conduit open to a server file or any other server side I/O pipe. These are secure connections.

    I can't say more because my knowledge fails me but Heater will be sure to pipe in to set us straight.

    It really does look like a win/win combination for portable cross-platform tools.
  • Heater.Heater. Posts: 21,230
    edited 2013-04-05 20:28
    Dr_A,
    Well, one thing Javascript should never be able to do is write to files on a computer
    That is true for JS in the browser. The trick here is that we are going to run JS programs outside of the browser. Just as if they were BASCIC, or Python, or Perl or whatever. We are going to use the node.js javascript run time.
    I am intrigued about the idea of GUI in a browser. If you can get it to talk to a serial port that would be very cool!
    To connect a Prop to a browser you need.
    a) Serial (or other link) from Prop to PC.
    b) Some process to handle that serial link on the PC.
    c) A webserver taking data to/from b) above to your browser.

    Plan is that b) and c) are the same program written in JavaScript and running
    under node.js.

    The code below reads and writes a serial port in JS and runs a web server all
    in 30 lines of code. All we need to do is connect the two together!
    "use strict";
    
    var SerialPort = require("serialport").SerialPort;
    
    var serialPort = new SerialPort("/dev/ttyS0", { baudrate: 115200 });
    
    serialPort.on("open", function () {
            console.log('Serial open.');
    
            serialPort.on('data', function(data) {
                    console.log('Serial received: ' + data);
            });
    
            setInterval(function() {
                    console.log("Writing serial\n");
                    serialPort.write("Some message\n");
            }, 1000);
    });
    
    var http = require('http');
    
    var server = http.createServer(function (req, res) {
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.end('Hello world!');
    });
    
    server.listen(8080);
    

    It only writes "Hello World!" to your browser but it's the start of everything.

    To run it from the command line we use:

    $ node prop-server.js

    and point a browser at http://localhost:8080
  • jmgjmg Posts: 15,173
    edited 2013-04-05 22:02
    Dr_Acula wrote: »
    I am intrigued about the idea of GUI in a browser. If you can get it to talk to a serial port that would be very cool!

    This discussion has just reminded me there is a Basic inside OpenOffice, and it seems there is OpenOffice on OS-X ?
    - so it is a similar idea to coat-tailing on someone else's large installation, only instead of a Browser, you use OpenOffice ?

    Google finds this :
    http://realterm.sourceforge.net/realterm_from_openoffice.html
    and this
    http://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=31686
  • Heater.Heater. Posts: 21,230
    edited 2013-04-05 22:03
    jmg,
    ...instead of a Browser, you use OpenOffice ?

    Sounds, like a nightmare.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-04-07 04:45
    I have done some more research on the original question on this post, namely that I can't compile (publish) vb.net 2010 programs. The problem is repeatable in 2010 C# with exactly the same error.

    I think the problem might be Windows 8, as there are no problems at all compiling exactly the same "Hello World" programs on Windows 7.

    So this might be a rather serious Windows 8 bug. Right now, the solution I am using is to write my programs on the Windows 7 machine, and then copy them over to Windows 8.

    For the purposes of creating simple programs that can run on multiple platforms, I am currently downloading virtualbox. Hmm, maybe I should run a win7 emulation on a win8 machine? *grin*

    Addit: installing XP in virtual box on the Win8 machine. Slightly disconcerting when you get to the install part where it asks "reformat hard drive with NTFS"....
  • Mike GMike G Posts: 2,702
    edited 2013-04-07 07:12
    DR_A, publish and compile (build) are two different things. A project is built when run from the Visual Studio editor. The result of the build, an exe or dll, is located in the project's bin folder. Publish builds the project and creates an install package which includes a manifest.

    The error you are seeing are related to setup.dll not being in the expected location on the build box. The .NET Framework SDK installs the the files required to create a setup package. A Visual Studio install should register the files as well.
Sign In or Register to comment.