DLL cannot see Main Module

Hi, this question is worth 300 points and they will be awarded to the individual that provides the best answer to my question.

I have an application that I've been working on for some time now (many Forms).  My colleague has also been working on other parts of this application and we're now at the stage of meshing it all together into one App.  Everything has worked fine thus far, except for the following problem described below:

I have a Main Module in my application that I call "modGlobalModule.vb".  I declare Public variables in that main module, which are used throughout the application.  When I added one of my colleague's Forms to my part of the application, his Form cannot see my Main Module or the global variables therein. I can see his Form, since I added a reference to it, and it runs OK, but I cannot add a reference back to my Main Module from his Form, so that it can see the global variables I need his Form to see. The reason I cannot do that is because my Project is not a DLL, its an EXE.

How do I get his Forms, that will all be added as DLLs into my part of the application, to see my Main Module and the global variables therein?

Thanks,
FDT
Mr_FulanoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

appariCommented:
Move the module to the DLL then both DLL and your EXE can see the global variables.
Mr_FulanoAuthor Commented:
OK that might work for one DLL, but what happens when I add the second one? Will the second, third, and forth DLLs see the Main Module as well?  Is there a way to have all the DLLs look up stream to the EXE instead of having the EXE look down stream to one of the DLLs.  After all, this Main Module is kind of the heart of where I make all my global declarations, so its really important that all the DLLs see it and can get their global variables from it.

Thanks,
FDT
appariCommented:
you have to  keep all the global variables and functions/subs in one main DLL and add reference to this DLL in all other DLL's and Exe's.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Mr_FulanoAuthor Commented:
Appari, that didn't work too well.  I created a new project to then add it as a DLL. I added a module to the project and copied everything in my current Main Module to the new module. As soon as I did that all the declaration references to my forms were lost in the new module. For example,

Public frmMyForm1 as New fclsMyForm1    (fclsMyForm1 has a blue squiggly line under it)
Public frmMyForm2 as New fclsMyForm2    (fclsMyForm2 has a blue squiggly line under it)
Public frmMyForm3 as New fclsMyForm3    (fclsMyForm3 has a blue squiggly line under it)
etc

Which makes perfect sense, as the new module doesn't have the slightest idea where all these forms are.  If I had to do as you suggested, I might have to do a lot of retrofitting. I would like to avoid that, because it far too much code to retrofit.

Is the a way to do it the other way around?

Thanks,
FDT

appariCommented:
are these frmMyForm1, frmMyForm2 etc are used in elsewhere in the global module?
do you want to access these forms from another dll too?
Mr_FulanoAuthor Commented:
Actually, no. The forms (i.e. frmMyForm1, etc) are mostly used in the main project that later becomes an EXE. The DLLs are other forms which could be "frmMyForm22" for example. However, let me explain what the problem is and maybe there's a workaround.  Say for instance I have a counter variable that counts the number of times all the forms open in a given session. All the forms would have to share that variable, because they would all need to add 1 to it each time they opened. In this example, one of my forms cannot see the main module and therefore cannot add its 1 each time it opens.  I need to be able to make sure all my forms DLLs or not, see my main module.

I could split the main modules into 2 modules. One module for the stuff that I need to keep in the main project and one module that I add references to so everybody can see it, but that can become a maintenance nightmare. I'm not sure that would be the best solution.

Suppose a developer has an application that has no DLLs and one day he/she decides to add a new form as a DLL. The new DLL will have to use all the variables that have been declared in the original project's main module for all the other forms. How would that developer grant access to the main module from the new DLL? -- This, I think, would solve my problem.

Thanks,
FDT
Mr_FulanoAuthor Commented:
Appari, as a followup to my last post, I do have one form that I have to leave inside the original main module and that will be referenced from all DLLs that are added to the project. So, my suggestion to split the main modules into 2 different ones just won't work. Any thoughts?

Thanks,
FDT
appariCommented:
In this case divide the main module to two separate modules. All the common code goes into module in the DLL and the remaining code keep it in the EXE. You can add the common form also to the DLL and reference it from EXE and other DLLS.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mr_FulanoAuthor Commented:
I tried it, that did not work. I need to find a way to make the DLL see the main module in the EXE without splitting them up.

I'm increasing the point value to 400 in hope of getting an answer to my question.

Thanks,
FDT
Mr_FulanoAuthor Commented:
Appari, I was able to find a better solution to my problem. I simply put the DLL into my EXE -- Job done!!!  I got some help on the .NET forum from one of the guys there, however, I'm convinced you really tried to help me, so I'm going to award you the 400 points even if we didn't find a solution here.  I still think having two main modules would be a very bad idea, so I decided to go with the simpler route.  Thanks for trying. -- FDT
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.