Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2006

Tip: Looking for answers? Try searching our database.

Need to split EXE into EXE and DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Petri - 16 Jun 2006 08:56 GMT
Hi,

I'm working on a piece of software that is now growing into a suite of
software products. When I started the work, I wasn't fully up to speed with
dotnet concepts (am I now either ;-), so the App is probably not built
accoridng to best practices.

Now I'm facing a situation, where I need to make a new module to the
software, but I don't want to compile everything into a single EXE because it
is getting quite large (already 2 MB+), so I thought about taking the shared
classes out of the current EXE into a separate DLL, and then the new App
would use the same DLL to access the shared items.

The problem is this. Many of the classes use other classes, and there are
also some globally defined objects that would need to be accessible to both
the EXE and the DLL.

Example:
I have a class called clSysSettings and I define a global object SysSettings
that is an instance of that class. Then I also have a class called clItem
that is used by objects in various places of the app. clItems also needs
access to Syssettings for various things. If the object SysSettings is
declared in Module1 of App.EXE, is it also available to Item objects based on
clItem which reside in the DLL ?

Of course I could change the way I use SysSettings and declare it privately
in each class, but there are a lot of classes in the app...

Thanks for any ideas !

Petri
Joanna Carter [TeamB] - 16 Jun 2006 09:39 GMT
| The problem is this. Many of the classes use other classes, and there are
| also some globally defined objects that would need to be accessible to both
| the EXE and the DLL.

Any class in the DLL is also available to both the DLL and to any other DLL
or EXE that holds a reference to that first DLL.

Joanna

Signature

Joanna Carter [TeamB]
Consultant Software Engineer

Petri - 16 Jun 2006 10:55 GMT
Hi Joanna,

I realize that, but what about an Object based on that class. If the object
is declared (globally) in the EXE, would it be accessible to classes declared
in the DLLs ?

ie.
EXE has  Public SysSettings as new clSysSettings

if the class in a DLL has this

Public Class clItem
    Public Sub LoadItem(ItemID as GUID)
       Private SQLcmd As SQLCommand=New SQLCommand ("<some
SQL>",SysSettings.cnSQL)
    End Sub
End Class

Would this work, ie would the SysSettings object be accessible to the Class
when teh Class resides in a different assembly to where SysSettings is
declared.

Petri

> | The problem is this. Many of the classes use other classes, and there are
> | also some globally defined objects that would need to be accessible to
[quoted text clipped - 5 lines]
>
> Joanna
Jesse Houwing - 16 Jun 2006 12:03 GMT
> Hi Joanna,
>
[quoted text clipped - 17 lines]
> when teh Class resides in a different assembly to where SysSettings is
> declared.

No this won't work. You'll have to move the global declaration to the
classlibrary aswell. Then it can be shared by the executable.

Jesse

> Petri
>
[quoted text clipped - 7 lines]
>>
>> Joanna
Petri - 16 Jun 2006 13:00 GMT
Thanks for the info

Can you do a global declaration in a DLL (scope would be DLL only) as well ?
I wouldn't want to go through all the classes to do it if I don't have to
(allthough that would be wise probably)

> > Hi Joanna,
> >
[quoted text clipped - 34 lines]
> >>
> >> Joanna
Joanna Carter [TeamB] - 16 Jun 2006 12:59 GMT
| I realize that, but what about an Object based on that class. If the object
| is declared (globally) in the EXE, would it be accessible to classes declared
| in the DLLs ?

You can't declare a "global" object without it being a static member of a
class.

Any public static member of any public class can be seen in any other
assembly that references the declaring assembly.

//assembly1

namespace My.Name.Space
{
 public static class MyGlobals
 {
   private static MyType myField = new MyType();

   public static MyType MyProperty
   {
     get { return myField; }
     set { myField = value; }
   }
 }
}

//assembly2 - references assembly1

namespace My.Application
{
 using My.Name.Space;

 public class SomeClass
 {
   public void Test()
   {
     MyType instance = MyGlobals.MyProperty;
     ...
   }
 }
}

Joanna

Signature

Joanna Carter [TeamB]
Consultant Software Engineer


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.