Common Object within DLL

  • Thread starter Thread starter C Glenn
  • Start date Start date
C

C Glenn

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?
 
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
 
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
 
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.
 
Please see my reply to Peter's post.

Fitim said:
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
 
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#.
 
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.
 
Back
Top