Need to split EXE into EXE and DLL

G

Guest

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
 
J

Joanna Carter [TeamB]

"Petri" <[email protected]> a écrit dans le message de (e-mail address removed)...

| 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
 
G

Guest

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
 
J

Jesse Houwing

Petri said:
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.

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
 
J

Joanna Carter [TeamB]

"Petri" <[email protected]> a écrit dans le message de (e-mail address removed)...

| 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
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top