473,624 Members | 2,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Instantiating CAO without using new operator

Hello All,

I want my clients to use my remoted object by means of interfaces. These
interfaces also ensure clean seperation between client and server.

The approach I know to instantiate a CAO is

RemotingConfigu ration.Register ActivatedClient Type(
typeof(MyObject ),
"tcp://localhost:1234/MyServer");
MyObject obj = new MyObject();

But I cannot do this because I am using an Interface for the client to
invoke the method on the server.

How to have an interface based client server coupling when using CAOs?

Thanks for your help in advance.

regards,
Abhishek.

Nov 16 '05 #1
5 1587
Hi Abhishek,

Check out the Activator.Creat eInstance method. This method can be used to create the instance of CAO using interface.

Take a look at the following links,

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpref/html/frlrfsystemacti vatorclasscreat einstancetopic. asp>

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dndotnet/html/introremoting.a sp>

Hope this helps...

--
Regards,
Madhu

Microsoft C# MVP | MCSD.NET
"Abhishek Srivastava" wrote:
Hello All,

I want my clients to use my remoted object by means of interfaces. These
interfaces also ensure clean seperation between client and server.

The approach I know to instantiate a CAO is

RemotingConfigu ration.Register ActivatedClient Type(
typeof(MyObject ),
"tcp://localhost:1234/MyServer");
MyObject obj = new MyObject();

But I cannot do this because I am using an Interface for the client to
invoke the method on the server.

How to have an interface based client server coupling when using CAOs?

Thanks for your help in advance.

regards,
Abhishek.

Nov 16 '05 #2
I have already tried Activator.Creat eInstance method. But it does not work.

The error message that will appear is

Unhandled Exception: System.MemberAc cessException: Cannot create an
instance of an interface.
at System.RuntimeT ype.CreateInsta nceImpl(Boolean publicOnly)
at System.Activato r.CreateInstanc e(Type type, Boolean nonPublic)
at Client.Main(Str ing[] args)

I am not providing the implementation of the remote object to the
client. The client binds only to the interface being implemented by the
remote object.

I found a solution which involves using soapsuds. However it works only
for the http channel whereas I want to use tcp channel.

regards,
Abhishek.

Madhu[C#-MVP] wrote:
Hi Abhishek,

Check out the Activator.Creat eInstance method. This method can be used to create the instance of CAO using interface.

Take a look at the following links,

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpref/html/frlrfsystemacti vatorclasscreat einstancetopic. asp>

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dndotnet/html/introremoting.a sp>

Hope this helps...

Nov 16 '05 #3
Hi,
can you post your CreateInstance line?

Also, you do not have to call RegisterActivat edClientType before that.

Sunny

In article <O3************ *@TK2MSFTNGP10. phx.gbl>, abhishek-
sr********@nosp am.net says...
I have already tried Activator.Creat eInstance method. But it does not work.

The error message that will appear is

Unhandled Exception: System.MemberAc cessException: Cannot create an
instance of an interface.
at System.RuntimeT ype.CreateInsta nceImpl(Boolean publicOnly)
at System.Activato r.CreateInstanc e(Type type, Boolean nonPublic)
at Client.Main(Str ing[] args)

I am not providing the implementation of the remote object to the
client. The client binds only to the interface being implemented by the
remote object.

I found a solution which involves using soapsuds. However it works only
for the http channel whereas I want to use tcp channel.

regards,
Abhishek.

Madhu[C#-MVP] wrote:
Hi Abhishek,

Check out the Activator.Creat eInstance method. This method can be used to create the instance of CAO using interface.

Take a look at the following links,

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpref/html/frlrfsystemacti vatorclasscreat einstancetopic. asp>

<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dndotnet/html/introremoting.a sp>

Hope this helps...

Nov 16 '05 #4
Abhishek,

You should call the version of CreateInstance which takes an array of
objects to use as activation attributes. The attribute that you will want
to pass is an instance of UrlAttribute, which specifies where the object
will be activated. Then, you have to unwrap the ObjectHandle that is
returned, and then cast that to the interface.

There is an example in the documentation for CreateInstance.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Abhishek Srivastava" <ab************ *****@nospam.ne t> wrote in message
news:O3******** *****@TK2MSFTNG P10.phx.gbl...
I have already tried Activator.Creat eInstance method. But it does not work.
The error message that will appear is

Unhandled Exception: System.MemberAc cessException: Cannot create an
instance of an interface.
at System.RuntimeT ype.CreateInsta nceImpl(Boolean publicOnly)
at System.Activato r.CreateInstanc e(Type type, Boolean nonPublic)
at Client.Main(Str ing[] args)

I am not providing the implementation of the remote object to the
client. The client binds only to the interface being implemented by the
remote object.

I found a solution which involves using soapsuds. However it works only
for the http channel whereas I want to use tcp channel.

regards,
Abhishek.

Madhu[C#-MVP] wrote:
Hi Abhishek,

Check out the Activator.Creat eInstance method. This method can be used to create the instance of CAO using interface.
Take a look at the following links,

<http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfsystemacti vatorclasscreat einstancetopic. asp>
<http://msdn.microsoft.com/library/de...-us/dndotnet/h
tml/introremoting.a sp>
Hope this helps...

Nov 16 '05 #5
there are many ways to do this. Check out my article here on a better
way of creating your CAO.

http://www.glacialcomponents.com/Art...cleID=CAOGuide

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com
On Tue, 22 Jun 2004 12:26:56 +0530, Abhishek Srivastava
<ab************ *****@nospam.ne t> wrote:
Hello All,

I want my clients to use my remoted object by means of interfaces. These
interfaces also ensure clean seperation between client and server.

The approach I know to instantiate a CAO is

RemotingConfig uration.Registe rActivatedClien tType(
typeof(MyObject ),
"tcp://localhost:1234/MyServer");
MyObject obj = new MyObject();

But I cannot do this because I am using an Interface for the client to
invoke the method on the server.

How to have an interface based client server coupling when using CAOs?

Thanks for your help in advance.

regards,
Abhishek.


Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3794
by: Matt Eberts | last post by:
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as a single argument? I'm sorry, this explanation is just atrocious, but I can't think of exactly how to word it. Maybe an example... Take for instance Function.apply. It takes 1-2 arguments, the first being the object to use as the context, and...
2
1541
by: pesso | last post by:
I have an array of filenames, which are paths to the .NET assembly DLLs I built. I know for sure that these assemblies have public method, Execute(). In the run-time, I want to be able to instantiate these assemblies from my CS code and invoke the Execute function. Can I do this without setting the reference in the compilation-time or using the "using" statement in the code? // Build the filename list. ArrayList filenames = new...
5
3624
by: Chris Kiechel | last post by:
I am writing a .NET Windows application and it needs to perform DDE calls to a legacy system. I created a C++ unmanaged class that performs the actual DDE connection and communication. However, I need .NET to instantiate this object and somehow allow the this object to callback to .NET. So, my question is: 1. How can a managed class instantiate and unmanaged class?
4
4136
by: Tom | last post by:
I have a VB.NET framework 1.1 application that I am installing on my user's workstation. It works fine on EVERY machine except for one - on this one machine it generates a 'Overflow or underflow in the arithmetic operation' when I attempt to instantiate my first form, as so: Dim frm As New frmMyForm() Based on some things I saw here, I thought it might be that this workstation didn't have a MS Sans Seriff font on it (since that is the...
3
4938
by: Nagesh | last post by:
hi, I have seen the winvnc(tightvnc server) source code in this I seen that class member funtions are calling without instantiating the object i.e. like vncService::ShowDefaultProperties() where vncService is a class name not an refrence or instantiated object. is the above notation is possible or not?if yes how should i declare that class(vncService) so that i can call without instantiating the object. If any of u know pls answer to...
5
4569
by: Anders Borum | last post by:
Hello! Whilst refactoring an application, I was looking at optimizing a ModelFactory with generics. Unfortunately, the business objects created by the ModelFactory doesn't provide public constructors (because we do not allow developers to instantiate them directly). Because our business objects are instantiated very frequently, the idea of using reflection sounds like a performance killer (I haven't done any tests on this, but the...
18
1853
by: RB | last post by:
Hi guys (and gals!), I've got 2 classes, "TypesafeConstant" and "Color". "Color" inherits from "TypesafeConstant", and adds no new functionality. All "Color" does is to instantiate some class variables which are public instances of "Color". What "TypesafeConstant" does is to create a shared list, and add every declaration of itself to that list. I can then query that list with a string (e.g. "Red") to return Color.Red.
4
4384
by: dascandy | last post by:
Hi, For a project I'm working on I'm kind-of-hacking my way around deriving a class from an interface or such to create a mock, but instead creating the mock directly. It is usable as the interface type (as the virtual functions match up), but there is a snag. No members are initialized, which means it can't be used as the original type if it has anything but virtual functions. It would be possible to make it work, if I could call the...
2
2533
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
Is the following code valid? #include <stdlib.h> #include <ostream.h> // compare *l to *r template <class T> int comparer(const T* l, const T* r) { if (*l < *r)
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.