Share dll object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

anybody knows how to share the dll between the process? I know there is a way
to set the #pragma data_seg in the visual studio 6.0 C++, that can make the
dll can be shared between the multiple processes. but how to do it in .net?
 
isamusetu said:
anybody knows how to share the dll between the process? I know there is a
way
to set the #pragma data_seg in the visual studio 6.0 C++, that can make
the
dll can be shared between the multiple processes. but how to do it in
.net?

What exactly do you need to share?
#pragma data_seg does not share a DLL!, it shares the "named" data segment
only, this option is not available (not needed) for managed code.
If it's your intention to share raw data your best option is memory mapped
files, when you need to "share" object instances take a look at remoting.



Willy.
 
Thanks, what I need is share the object between the process, because we are
thinking to make a project which will has 3 layers(web server, app server,
database server), for example, the app server will incharge the database
access, if the database connection object can be shared between the processes
on the app server, this object dont need create and disposed time to time.

Thats my target, and you said the remoting can implement it, I see. is there
any other way to do like remoting(more simple more better)

Warm regards.
 
But why would you share a Database connection object if only the app server
is in charge of the DB access?

Willy.
 
if the database connection object is always in the memory, I don't need to
new() and dispose() it time to time right? if there isn't, when the module A
startup, A should new a object and dispose it when A exit, and module B
startup, B should new a object and dispose it same as A did, that will take
the cpu time.

the database connection object is just a sample here, if we hava some dll
can be used for lots of modules, if those objects in the dlls can be created
only once, I think the system will be faster.

Sure I know some object can not be shared between the different processes,
but would you tell me is there the way to implement this function in the .net?
 
Thank you, you can see what I want to do below.

--
ISAMUSETU


Miha Markic said:
Remoting?
What exactly do you want to share?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

isamusetu said:
anybody knows how to share the dll between the process? I know there is a
way
to set the #pragma data_seg in the visual studio 6.0 C++, that can make
the
dll can be shared between the multiple processes. but how to do it in
.net?
 
Hi,

isamusetu said:
if the database connection object is always in the memory, I don't need to
new() and dispose() it time to time right? if there isn't, when the module
A
startup, A should new a object and dispose it when A exit, and module B
startup, B should new a object and dispose it same as A did, that will
take
the cpu time.

It is a bad example. You should use connection object per thread and it
should be opened as late as possible and closed asap.
Sharing such object doesn't make sense and performace will go down to the
ground.
the database connection object is just a sample here, if we hava some dll
can be used for lots of modules, if those objects in the dlls can be
created
only once, I think the system will be faster.

No it won't. Generaly speaking you are better off creating each object in
the application itself - otherwise you'll loose time with remoting (it costs
you) and also you'll have to implement locking mechanism which might be a
bottleneck and again, you can loose much time here. You should consider
sharing objects in rare cases.
Another problem is that if you implement remoting your shared objects have
to live in a separata process (which will consume resources and cpu cylces,
too).
Sure I know some object can not be shared between the different processes,
but would you tell me is there the way to implement this function in the
.net?

So, the bottom line is - avoid sharing unless really necessary.
 

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

Back
Top