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

Posted on 2005-04-28
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

    Author Comment

    I should add that MapList is a public collection of forms

    Author Comment

    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

    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.

    Author Comment

    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

    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

    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


    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

    Very kind.  Thank you:)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now