?
Solved

DLL cannot see Main Module

Posted on 2006-07-23
10
Medium Priority
?
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 39

Expert Comment

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

Author Comment

by:Mr_Fulano
ID: 17165846
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
ID: 17165861
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
Technology Partners: 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

by:Mr_Fulano
ID: 17165925
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
ID: 17166004
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
 

Author Comment

by:Mr_Fulano
ID: 17172803
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
ID: 17173059
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 800 total points
ID: 17173199
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
ID: 17173245
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
ID: 17206332
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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 …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 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