Run-time error '50304' An instance of formxxx cannot be created because its designer window is open

Posted on 2005-04-28
Medium Priority
Last Modified: 2013-12-25
I have a VB app I have been working on in VB6 that runs fine when run in the IDE

When I attempt to make a standalone exe (lets call it xxx.exe) the act of doing so generates the error message listed above.

Apparently, one of the first thing the IDE does when building xxx.exe is to actually run the program.

During this "run" the program encounters the above error that it does not encounter when invoked in the IDE via the run menu.

When it encounters a problem, it lets me debug and reveals that it is stuck on the following line of code:

 AddMapDefinition "formabc", frmAbc

(where frmABC is a form I defined in the project) This form contains custom controls that I wrote.

The actual code that makes up AddMapDefinition is listed below:

Public Sub AddMapDefinition(sName As String, frm As Form)
    Dim map As New CMapLink
    map.Create sName, frm
    MapList.Add map, sName
End Sub

CMapLink is a very straightforward class I wrote, made up of the following lines:

' CMapLink.cls
Option Explicit
Public m_sName As String
Public m_frmMap As Form
Public Sub Create(sName As String, frm As Form)
    m_sName = sName
    Set m_frmMap = frm
End Sub

The form contains instances of controls I wrote and I am assuming it is not necessary to provide the listing for them here.

I searched the site for 50304 as well as Google and was unable to determine how the things described applied to my problems. Apparently the IDE is confused about the "application" (??) or component within the IDE ( a designer?) used in some way in the creation of the form ?

I have tried explictily closing files, saving project, stopping IDE and restarting it without success. I even rebooted machine several times. Any help greatly appreciated.

Question by:smm27
  • 5
  • 2

Author Comment

ID: 13887037
I should add that MapList is a public collection of forms

Author Comment

ID: 13889696
Also, another noteworthy observation. I have the same project on another machine also using VB 6. On the other machine, I am able to do the make exe w/o error. Then, if I copy all of the files (all inclusive) in the projects directory on the "good machine" to the project directory on the "bad machine" and try to make exe I still get the same error. I am now going to make sure that the IDE is in fact using the files only from this directory by checking each source file's properties.
LVL 10

Assisted Solution

edwardiii earned 500 total points
ID: 13890424
Hi, smm27.

Has "formabc" been added to your MapList?  Whether it has or not, can you create your .exe with that form removed from your project?  I'm wondering if we can delete/re-add that form and get your project on the 'bad' machine to work.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 13890683
OK..thanks for that suggestion, I did not mention that in fact, I tried many combinations of running the project in the IDE, then attempting to make exe. Remove form (and any refs to it in code from the project, at which point I was able to build the exe). I have had this problem in the past I guess the key (or one key) is where is the data store that holds the information used to indicate a form's "designer is open" ?

When you say delete, I am assuming you mean remove from project and not delete the .frm itself...

This is a legacy app I inherited and would not want to "remake" the form.

In the past when I have loaded a pre-existing .frm file into a VB project, if there are errors in the .frm file (i.e. a .frx file that does not exist is specified or something like that) a log file is made containing text of the errors...when I reload this form into the project, no such error produced....

I am thinking it may be related to some rsource I may have clobbered somehow but that it just a gut feeling, not sure. At any rate, I think we can say I tried the remove form from project, save it, exit VB then restart and reload form without good result. Also variotions on sequence (compile and run in IDE, then try make exe, just try make .exe, etc etc etc.)
Also, if I comment out the AddMapDefinition statement, the build of exe works no problem, as you would expect...

Any ideas as to where the flag (either actual or logical) get set saying "designer for this form should be considered open" cause that's what seems to be the problem. Thanks much

LVL 27

Accepted Solution

Dabas earned 500 total points
ID: 13890836
Hi smm27,
> Apparently, one of the first thing the IDE does when building xxx.exe
> is to actually run the program.
I think this is a wrong assumption.
When the IDE builds and IDE it creates several temporary object files, then links them to create the executable.
I think here it is where things are failing for you. Probably it is hitting some kind of permission issue on that particular system.
Are you logged in as Admininstrator? Is maybe a virus checker stopping the IDE from creating the .obj files?


Author Comment

ID: 13893896
I am am member of Administrator group with full priviledges thereof. The reason I came up w/ idea that it runs the program (see initial description) is that the act of Make exe generates an exception that lets me choose End Debug or Help which is same thing happens when you run pgm in IDE and it encounters exception or fault.

SOMETHING is telling the IDE, during its attempt to build the executable that "Its designer window is open". Whether the designer window is open or this is a shadow error of something else that has gone on previously, I cannot say. I am thinking it is something corrupted in one of the control objects that are contained within the form....this is line of attack a I am pursuing. Otherwise, all of this should be going on in process space of the IDE such that permissions should not be an issue (they never were previously).

Author Comment

ID: 13894153

Apparently, when the VB IDE goes about "making an exe", it "runs some code but not per-se the application itself. It seems to "run" each form's initialization methods.....

I had a diagnostic write in the form's initialization code that required that a log file been opened previously... The application opened this log file when it started, the initialization of the form did not !
I guess the lesson learned here was to make forms as self-contained as possible and to NOT have them depend on any code or objects other than themselves or anything they contain.....

Not sure about "policies of the board" but I will give some points to those who tried because they spent time doing so.....even though none of answers were the actual cause...
LVL 10

Expert Comment

ID: 13958953
Very kind.  Thank you:)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question