Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more: (untagged)
We have just converted a large VB6 program (30 screens with code behind and 40 modules to VB.Net, First 2005 and then 2008 Net 3.5) on Win 7/64 but running in x86 mode.

It uses the same techniques as our other .Net apps with multple form variables pointing to the same real form i.e.
VB
Public FormMain as frmMain = frmMain
Public FormStores as frmMain = frmMain

This is in a module. frmMain is the startup form. Application Framework is enabled.

This has been working in other programs just fine for years.

However with this program it fails.
The first = frmMain gets an exception that doesn't show up until later
(the instructions after this one do not execute).

Later we get
The type initializer for ... threw an exception
The inner exception is
'The form referred to itself during construction of a default instance, which led to an infinite recusion. ...'

on
AppFrameWorkOn2 = True

which is AFTER the
Public FormMain as frmMain = frmMain

Why is this not working in ths program but does in others?

Have tried
Public FormMain As New frmMain
which does not cause the error but this has different results. FormMain is no longer a reference to frmMain but a totally new form and the controls settings will be different as the user changes them.

How do I get this to work??

Please help!!!
Posted
Updated 17-Sep-11 6:47am
v2
Comments
Sergey Alexandrovich Kryukov 18-Sep-11 19:36pm    
What is frmMain, a type or an instance? What is AppFrameWorkOn2?!
--SA

1 solution

The fragment "New frmMain" suggests this is a type. How can it possibly have "references"? You seemingly have no idea of some basics of programming. The code fragments you show looks like gibberish (http://en.wikipedia.org/wiki/Gibberish[^]).

Do the following:

1) Create a brand-new VB.NET program with Visual Studio from a template. Add one or too controls to the main form using the Toolbox. It will create you a fully working skeleton of the application. Examine its structure and understand how it works. You will need to create something very similar in your port.

2) Get familiar with basics of .NET programming and VB.NET. Learn types, instances, static and instance members, properties, basics of classes inheritance and virtual methods/properties, late binding. Anything else. Yes, but what I already listed is enough to start. Make sure you thoroughly understand it. You should also understand that the Designer only helps you to write the code (or confuse someone in doing so, it depends on the skills and the point of view :-)); all the artifacts of programming are cast in the source code which is build without any participation of the Designer.

—SA
 
Share this answer
 
Comments
Simon Bang Terkildsen 18-Sep-11 20:09pm    
My 5
Sergey Alexandrovich Kryukov 18-Sep-11 20:43pm    
Thank you, Simon.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900