Loading...
 
Multi-Language Add-In for Visual Studio

Multi-Language Add-In for Visual Studio


Adding language selection form to VB.NET project generates bad code

Germany

The Multi-Language Add-In has a feature to add a language selection form to a Windows Forms project and to show the form automatically when the application is started. Unfortunately, this feature generates bad code for VB.NET projects using Visual Studio 2005 or 2008. I believe that it worked for Visual Studio 2003, but I am sorry to admit, that it has never worked with Visual Studio 2005, unless the project already had a user coded Sub Main().

In order to show the language selection form before the main form of an application is loaded, the Add-In will add a few lines of code to Sub Main(). However, VB projects do not usually need an explicit Sub Main(), so the Add-In starts be creating a Sub Main() and making it the startup object.

Visual Studio 2005 introduced the MyApplication object and effectively broke this code. If you want to have an explicit Sub Main() you now have to uncheck the option "Enable application framework" on the application properties page. One way to fix the code would be clear this option automatically. (I don't actually know how to do this, but I'm sure it is possible).

However, with Visual Studio 2005, there is a better solution. The MyApplication object can generate a Startup event, which is fired before the startup form is shown. This is the ideal time to show the language selection form.

To do things properly, the Add-In ought to make a distinction between projects which already have a Sub Main() and project which use the application framework. In the first case, it can add code to Sub Main, otherwise it should add code to the MyApplication_Startup event, which it should create if necessary.

I will try to fix this problem soon, but if anybody runs into this bug, I suggest you generate the MyApplication_Startup event by hand and move the code to show the language selection form from the Sub Main() generated by the Add-In (which can then be removed).

Phil
5th March 2008

Germany

Version 4.53.0005 fixes this problem.

I have more or less rewritten the logic for adding the Language-Selection Dialog to a project and it should handle the cases:

  • VB project with application framework
  • VB project without application framework
  • C# project
  • C++ project

properly.

There is a description of what it does in the help file.

Phil
24th March 2008