Share objects

G

Guest

H

I want to make a project where one or more object could be shared between 2 applications

For example : the first application create a connection to a web-service, this connection is stored in an object (through a service perhaps). A second application is launch and I want this application, use the same connection as the frst one (so retrieve the object where the connection is stored)

Any idee of th process ??

I think I need to create a COM+ services but I don't understand all the process to retrieve my object..

Thx a lo

Ashura
 
P

Pete Wright

Simply create an class that implements ISerializable in an assembly, and
then reference that assembly in both applications. You would then be able to
pass serialized instances of that class between the two applications using
SOAP (Web services), Message Queues or any other method you require.

Hope that helps
--
--------------------------------------------------------
Peter Wright (www.petewright.org)
Author of ADO.NET Novice To Pro
From Apress. www.apress.com (and 10
other doorstops from Wrox)


Ashura said:
Hi

I want to make a project where one or more object could be shared between 2 applications.

For example : the first application create a connection to a web-service,
this connection is stored in an object (through a service perhaps). A second
application is launch and I want this application, use the same connection
as the frst one (so retrieve the object where the connection is stored).
Any idee of th process ???

I think I need to create a COM+ services but I don't understand all the
process to retrieve my object...
 
G

Guest

Thanx for your response, but I don't think I can do what I need with the Iseriazable
I need a method which follow this proces

X starts, if there is no object AA (where is stored Data and Connection) I create A
Y starts, it tryes to retrieve AA to obtain Data and Connectio
When Y or X stops, AA is still alive (because there is always 1 object who use AA

X and Y can be switched (Y can be started before X

I don't know how I need to create the object A

Thx a lot for your read and your respons

Ashura

----- Pete Wright wrote: ----

Simply create an class that implements ISerializable in an assembly, an
then reference that assembly in both applications. You would then be able t
pass serialized instances of that class between the two applications usin
SOAP (Web services), Message Queues or any other method you require

Hope that help
--
-------------------------------------------------------
Peter Wright (www.petewright.org
Author of ADO.NET Novice To Pr
From Apress. www.apress.com (and 1
other doorstops from Wrox


Ashura said:
this connection is stored in an object (through a service perhaps). A secon
application is launch and I want this application, use the same connectio
as the frst one (so retrieve the object where the connection is stored)
 
P

Pete Wright

Interesting problem. First up let's look at the connection part. Personally
I wouldn't pass a connection object around between applications. The reason
is that in .NET it's good practice to limit the scope of a connection as
much as possible to conserve resources. This isn't as much as a problem as
you might think it is in your case. ADO.NET will automatically handle
connection pooling so long as both applications use precisely the same
connection string. This means the hit in creating the connection object the
second, third, and so on, number of times is far less than it is the first
time. So, instead of passing the connection object itself around, just pass
the connection string.

In the applications themselves, use this string to build your connection
object, hit the database to what you need then disconnect and close the
connection as soon as possible. In .NET the issue I imagine you are trying
to solve by passing a connection object around really doesn't exist. You
just need to think a little different.

On the data side, serialization really should work. You are, after all, just
talking about data, and again it comes down a little to design and best
practices. Try to keep all your classes as loosely coupled and cohesive as
possible. That is to say, code in a class should focus on doing one thing,
and doing it well, and should be designed such that the class could easily
be re-used in any other application since it has no hard ties to other
classes or objects. This sounds like designing for re-use, and it is, but
you'll find a number of other benefits from working this way. Have a crack
at it. Look at your class and object structure and ask yourself - could this
be designed differently to make the classes lighter, more efficient and
solve the other issues I have. You may be surprised by what you find.


An alternate approach though would be to have a single utility application,
service or even a web service that handles your data tier work. That single
application could create the connections, hit the database and grab the data
you want, before serializing it and passing it on to a requesting
application. Again this means limiting the scope of the connection object
itself, but it does address what seems to be a fairly large need of yours,
and that is to have a single persistent data access layer in your code.

Does that help ?
 
G

Guest

The problem is interesting (I know that), but I not found a solution Yet

Your propositions are interesting, but, are not "allowed"

I need to save the connection because the applications will be connected to a server by identification. This server is a stream server

It's like a TV-stream.

The first application connect to the server (with identification), the server gives the stream and the data is like movies

When a second application is launched on the same computer, I want only that the new process uses the connection created before and the objects (videos) downloaded before. And not make another connection (so another identification, another stream because there is a stream yet

It's why I need a solution to store in a boject my connection and my data
I think I need to use Com or Com+ and services. But I don't know yet how the first process can launch a server to be accessible. It work when I launch a server and after my process, but not when my process launch the server

Your solution

An alternate approach though would be to have a single utility application
service or even a web service that handles your data tier work. That singl
application could create the connections, hit the database and grab the dat
you want, before serializing it and passing it on to a requestin
application. Again this means limiting the scope of the connection objec
itself, but it does address what seems to be a fairly large need of yours
and that is to have a single persistent data access layer in your code

is what I try. But I have a little problem : this third application may be launched by another process and could not be launched before

Thx for your reponse
Sorry for my english (I'm french but my question is too hard for the french community, too few people uses C# in France
Sorry for the time I read you

Ashur

----- Pete Wright wrote: ----

Interesting problem. First up let's look at the connection part. Personall
I wouldn't pass a connection object around between applications. The reaso
is that in .NET it's good practice to limit the scope of a connection a
much as possible to conserve resources. This isn't as much as a problem a
you might think it is in your case. ADO.NET will automatically handl
connection pooling so long as both applications use precisely the sam
connection string. This means the hit in creating the connection object th
second, third, and so on, number of times is far less than it is the firs
time. So, instead of passing the connection object itself around, just pas
the connection string

In the applications themselves, use this string to build your connectio
object, hit the database to what you need then disconnect and close th
connection as soon as possible. In .NET the issue I imagine you are tryin
to solve by passing a connection object around really doesn't exist. Yo
just need to think a little different

On the data side, serialization really should work. You are, after all, jus
talking about data, and again it comes down a little to design and bes
practices. Try to keep all your classes as loosely coupled and cohesive a
possible. That is to say, code in a class should focus on doing one thing
and doing it well, and should be designed such that the class could easil
be re-used in any other application since it has no hard ties to othe
classes or objects. This sounds like designing for re-use, and it is, bu
you'll find a number of other benefits from working this way. Have a crac
at it. Look at your class and object structure and ask yourself - could thi
be designed differently to make the classes lighter, more efficient an
solve the other issues I have. You may be surprised by what you find


An alternate approach though would be to have a single utility application
service or even a web service that handles your data tier work. That singl
application could create the connections, hit the database and grab the dat
you want, before serializing it and passing it on to a requesting
application. Again this means limiting the scope of the connection object
itself, but it does address what seems to be a fairly large need of yours,
and that is to have a single persistent data access layer in your code.

Does that help ?


--
 

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