Solved

DLL cannot see Main Module

Posted on 2006-07-23
10
168 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:Mr_Fulano
  • 6
  • 4
10 Comments
 
LVL 39

Expert Comment

by:appari
Comment Utility
Move the module to the DLL then both DLL and your EXE can see the global variables.
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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
0
 
LVL 39

Expert Comment

by:appari
Comment Utility
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.
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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

0
 
LVL 39

Expert Comment

by:appari
Comment Utility
are these frmMyForm1, frmMyForm2 etc are used in elsewhere in the global module?
do you want to access these forms from another dll too?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Mr_Fulano
Comment Utility
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
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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
0
 
LVL 39

Accepted Solution

by:
appari earned 400 total points
Comment Utility
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.
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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
0
 

Author Comment

by:Mr_Fulano
Comment Utility
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
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

10 Experts available now in Live!

Get 1:1 Help Now