John C. Kirk (johnckirk) wrote,
John C. Kirk
johnckirk

Today I got my copy of Visual Studio 2005 through the post, so I've been having a play with that, by upgrading some of my VB.NET 2003 projects. Unfortunately, I got a rather confusing error message from them, and I couldn't find much info on the web. I've partially figured it out, so I'm documenting it here for other people's benefit.

The error is something like this:
'FMain' is a type in 'Presentation' and cannot be used as an expression.
where FMain is the name of my startup form and Presentation is the name of the project. However, there's no line number given, and I can't find any code that refers to the form.

If I then go to Project Properties, and check the box for "Enable application framework", that displays an error message that says "Startup object must be a form when 'Enable application framework' is checked.". I'm not sure why it says that, since the startup object is a form (i.e. it inherits from System.Windows.Form), but if I find a different form that the framework checkbox will accept then that also fixes the compilation error.

What I'm now trying to do is figure out why it accepts some forms and not others. A newly created form is fine, so there may be some legacy code in my older forms (particularly if they originally started out life in VB6). I think it may also have something to do with the "Localizable" attribute being set, but that could be a red herring.

The corollary to that is that you can create a new form, set that as the startup object, then enable the application framework, and this is pretty much guaranteed to work. Once you've done that, the "startup object" dropdown list is renamed to "startup form", and it is filtered to what VB presumably considers to be a valid list; this gives a starting point for a fun game of "spot the difference".

Edit: Hah, gotcha, you bastard! It turns out that the "Sub New" method in the startup form has to be Public (rather than Friend). That's the default for new forms, but I've been changing that for all of mine in the past, to improve security ("don't expose any more info than you need to").
Tags: computers
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment