471,347 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Dynamically linking to webservice or COM DLL

I have a C# client application that uses a COM DLL(written in C++) or
a webservice (the
webservice is the same COM DLL wrapped up as a webservice). The client
can dynamically (based on form input) select to use the webservice or
the DLL. The front end interface and the implementaion code is the same

in either case. However the namespace and the main class used in either

case are different.
Is there anyway to implement this efficiently ?
Thanks in advance.

Jan 10 '06 #1
5 2238
lavu,

The best way to do this would be to use an interface, and implement a
class factory pattern. The COM object and the proxy would both implement
the interface, and then you can have a class factory create an
implementation when needed, based on the circumstances.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"lavu" <th******@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I have a C# client application that uses a COM DLL(written in C++) or
a webservice (the
webservice is the same COM DLL wrapped up as a webservice). The client
can dynamically (based on form input) select to use the webservice or
the DLL. The front end interface and the implementaion code is the same

in either case. However the namespace and the main class used in either

case are different.
Is there anyway to implement this efficiently ?
Thanks in advance.

Jan 10 '06 #2
Thank you. I am not familiar with the class factory pattern and am
going to read more about it.

Jan 10 '06 #3
I am re- introducing this thread after exploring the Class Factory
Pattern and
determining that it would not be suitable for me. The main reason is
that
the base class needs to be the same for both and in my case, the web
service and
the COM implementation does not have a common base class.
Are there any other ideas to implement this ?

Jan 11 '06 #4
lavu,

For a class factory to work, they don't necessarily have to have the
same base class. They can share the same interface implementation. You CAN
do this in this case, which is what I actually recommended in my previous
post.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"lavu" <th******@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I am re- introducing this thread after exploring the Class Factory
Pattern and
determining that it would not be suitable for me. The main reason is
that
the base class needs to be the same for both and in my case, the web
service and
the COM implementation does not have a common base class.
Are there any other ideas to implement this ?

Jan 11 '06 #5
Nicholas,

Thanku for your efforts. I am hoping you can help me with some
suggestions based on the scenario that I will explain below:

I have a COM dll from which I can instantiate an object of type Class A
in my client.
I have a webservice from which I can instantiate an object of type
Class B in my client.
I need to have a common reference to either object which will be done
at run-time. I do not have access to the actual DLL or the webservice.
How can I use an interface to implement this ?

Jan 11 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Germic | last post: by
3 posts views Thread by T-Man | last post: by
reply views Thread by Kristof Thys | last post: by
1 post views Thread by Ed S | last post: by
2 posts views Thread by Call Web service dynamically. | last post: by
36 posts views Thread by Martin Larsen | 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.