472,122 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

Common Object within DLL

I would like to instantiate an object within a DLL for the classes
within the DLL to make use of. Is there a way to cause the DLL to
instantiate an object within itself when it is first called into action
or by some other event?
Nov 23 '05 #1
6 1346
Why do you want to do it? What is the purpose ? When you create DLLs (Class
Libraries) you can isntanitate any object from that DLL without any problem.

If you would explain yourself better (explain the problem you are trying to
solve) then someone might help you better.
Fitim Skenderi
"C Glenn" <no****@domain.com> wrote in message
news:ee*************@TK2MSFTNGP10.phx.gbl...
I would like to instantiate an object within a DLL for the classes within
the DLL to make use of. Is there a way to cause the DLL to instantiate an
object within itself when it is first called into action or by some other
event?

Nov 23 '05 #2
I think you need to clarify what you mean by "Object" when in the next
sentence you say "the classes". In .NET, an "object" is an instance of a
class.
If that's what you mean, it can be done in the contructor.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"C Glenn" wrote:
I would like to instantiate an object within a DLL for the classes
within the DLL to make use of. Is there a way to cause the DLL to
instantiate an object within itself when it is first called into action
or by some other event?

Nov 23 '05 #3
Three classes within the DLL need to know the status of a specific table
within a database. So I've created a class that, when instantiated,
checks the status of that table, comparing it to the same data stored
locally in an XML table. The objects instantiated from the three
classes mentioned above can then make decisions based upon the
differences between the data on the server and the data within the XML
table. Naturally, I would like to consume the necessary resources and
network bandwidth as infrequently as possible.

The obvious thing to do is instantiate the object that makes this
comparison when the application first opens. But, it occurred to me
that there might be an inialization event within a DLL that would ensure
that this took place even if someone else used the same DLL for another
application in the future.

Another possibility would be to cause each instantiation of each of the
three classes that need this information to check for it themselves, but
then again, I would like to conserve resources and bandwidth.

Thanks for your help.

Peter Bromberg [C# MVP] wrote:
I think you need to clarify what you mean by "Object" when in the next
sentence you say "the classes". In .NET, an "object" is an instance of a
class.
If that's what you mean, it can be done in the contructor.
Peter

Nov 23 '05 #4
Please see my reply to Peter's post.

Fitim Skenderi wrote:
Why do you want to do it? What is the purpose ? When you create DLLs (Class
Libraries) you can isntanitate any object from that DLL without any problem.

If you would explain yourself better (explain the problem you are trying to
solve) then someone might help you better.
Fitim Skenderi
"C Glenn" <no****@domain.com> wrote in message
news:ee*************@TK2MSFTNGP10.phx.gbl...
I would like to instantiate an object within a DLL for the classes within
the DLL to make use of. Is there a way to cause the DLL to instantiate an
object within itself when it is first called into action or by some other
event?


Nov 23 '05 #5
I think one solution is to meka the classes that read the data from the
table as singletons assuming you will only read the data from the table
once, or if you need to get data from the table infrequently then you can
add a method to your singleton to refresh the loaded data from the table.

Fitim Skenderi

p.s. I know that in win32 apps, when you created a DLL in delphi (not COM,
but plain DLL), you had functions that you could implement upon loading the
DLL and upon unloading the DLL , but I haven't come accross anything like
that in C#.
"C Glenn" <no****@domain.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
Three classes within the DLL need to know the status of a specific table
within a database. So I've created a class that, when instantiated,
checks the status of that table, comparing it to the same data stored
locally in an XML table. The objects instantiated from the three classes
mentioned above can then make decisions based upon the differences between
the data on the server and the data within the XML table. Naturally, I
would like to consume the necessary resources and network bandwidth as
infrequently as possible.

The obvious thing to do is instantiate the object that makes this
comparison when the application first opens. But, it occurred to me that
there might be an inialization event within a DLL that would ensure that
this took place even if someone else used the same DLL for another
application in the future.

Another possibility would be to cause each instantiation of each of the
three classes that need this information to check for it themselves, but
then again, I would like to conserve resources and bandwidth.

Thanks for your help.

Peter Bromberg [C# MVP] wrote:
I think you need to clarify what you mean by "Object" when in the next
sentence you say "the classes". In .NET, an "object" is an instance of a
class.
If that's what you mean, it can be done in the contructor.
Peter

Nov 25 '05 #6
Thank you. I come from Delphi and, although I wasn't really clear about
it initially, it was the Initialization feature that I was thinking of.

Fitim Skenderi wrote:
I think one solution is to meka the classes that read the data from the
table as singletons assuming you will only read the data from the table
once, or if you need to get data from the table infrequently then you can
add a method to your singleton to refresh the loaded data from the table.

Fitim Skenderi

p.s. I know that in win32 apps, when you created a DLL in delphi (not COM,
but plain DLL), you had functions that you could implement upon loading the
DLL and upon unloading the DLL , but I haven't come accross anything like
that in C#.
"C Glenn" <no****@domain.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
Three classes within the DLL need to know the status of a specific table
within a database. So I've created a class that, when instantiated,
checks the status of that table, comparing it to the same data stored
locally in an XML table. The objects instantiated from the three classes
mentioned above can then make decisions based upon the differences between
the data on the server and the data within the XML table. Naturally, I
would like to consume the necessary resources and network bandwidth as
infrequently as possible.

The obvious thing to do is instantiate the object that makes this
comparison when the application first opens. But, it occurred to me that
there might be an inialization event within a DLL that would ensure that
this took place even if someone else used the same DLL for another
application in the future.

Another possibility would be to cause each instantiation of each of the
three classes that need this information to check for it themselves, but
then again, I would like to conserve resources and bandwidth.

Thanks for your help.

Peter Bromberg [C# MVP] wrote:
I think you need to clarify what you mean by "Object" when in the next
sentence you say "the classes". In .NET, an "object" is an instance of a
class.
If that's what you mean, it can be done in the contructor.
Peter


Nov 25 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Jan van Veldhuizen | last post: by
3 posts views Thread by R.A.F. | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.