Creating a CAO instance in the same application where it is hosted

dotnet framework

Creating a CAO instance in the same application where it is hosted

Postby SGFyaQ » Fri, 17 Mar 2006 22:41:32 GMT

Hi,

I have a CAO component which is hosted by my server. This server also 
contains function, in which i need to create an instance of this CAO. 
(This CAO object has to be passed to another process)

When I first tried to create CAO component using overloaded 
Activator.CreateInstance() method with activationAttributes that has URL 
properties, I got the following exception:

"Invalid Internal State: MarshalByRefObject should not have proxy object in 
the same AppDomain"

To overcome this, I created a new AppDomain and used CreateInstance function 
of AppDomain to create an instance of the CAO.

This function returns an reference of type ObjectHandle. When I try to 
typecast it to the CAO component type i am getting "InvalidCastException".

If I use, ObjHandle.UnWrap() the instance is no longer behaving like a 
proxy. It is a local component and i cannot pass it to another process.

Even if i send ObjHandle to another process, once it unwraps objHandle it 
becomes a local instance which it cannot use.

Is there any other way i can over come this.

Any Suggestion or input on this will help me a lot

Regards
Hari 


Re: Creating a CAO instance in the same application where it is hosted

Postby p.balamurali » Sat, 18 Mar 2006 10:08:39 GMT

I understand you have some thing like this .
class ABC : MBR{
  public ABC fn ( ..... ) {} }

I think you have to just do a <new> of  your CAO type, set the initial
lease if you want to do that and return it .
As ABC is MBR type the remoting infrastructure should take care of
marshalling appropriately based on the kind of remoting boundaries that
span the call.

the question I would have for you is ,Can you not have a factory
component that churns out this CAO component ?

Regards , 
Murali.


Re: Creating a CAO instance in the same application where it is hosted

Postby BM » Sun, 19 Mar 2006 03:24:45 GMT

Hari ,

BTW I was just suggesting factory for abstracting creation details ...








Similar Threads:

1.Creating a CAO instance in the same application where it is ho

Hi,

Thanks for the reply.

But my scenario is like this.

I have hosted a SAO and CAO Server component in a Service. There is another 
service which is hosting a CAO component. Lets say SAO1, CAO1 and CAO2 hosted 
in Service1 and Service2 respectively (There is a possibility that this CAO2 
might be hosted by Service1).

SAO1 should create an instance of CAO1 and pass this instance as a method 
parameter to one of the functions of CAO2.

I cannot have <Client> tag in my Config file of Service1 as the same Config 
file is being used for Hosting these components and as such i cannot use new 
to create CAO1, because it will result in creation of only local instance.

Can you suggest me how factory might help me in solving this problem

Regards
Hari

" XXXX@XXXXX.COM " wrote:

> I understand you have some thing like this .
> class ABC : MBR{
>   public ABC fn ( ..... ) {} }
> 
> I think you have to just do a <new> of  your CAO type, set the initial
> lease if you want to do that and return it .
> As ABC is MBR type the remoting infrastructure should take care of
> marshalling appropriately based on the kind of remoting boundaries that
> span the call.
> 
> the question I would have for you is ,Can you not have a factory
> component that churns out this CAO component ?
> 
> Regards , 
> Murali.
> 
> 

2..NET Remoting HOST always creating new instances

I am trying to create a remoting host where I have a datatable and the
client simply adds rows to the datatable and has the possibility to fetch
the whole datatable.
Every request they make always re-initializes my library so my datatable
becomes a blank one with every new request.What I was looking for is that
once I start my host my datatable will stay in memory until I terminate it
and not with every call to the host.

I hope I am explaining myself correctly :)
TIA,
Ahmed


3.How to create Word application instance from .Net Web application

Hello,
I'm working on word automation through .Net web application.
Whenever I try to create an instance of word application is says "The 
message filter indicated that the application is busy".Please help me.
Thanks in advance.

4.Need help with CAO Objects/Singleton Objects Hosted in IIS

5.Passing CAO reference back to remoting host

Hi,

i have a little Problem with a CAO reference.

On client side i use a code like this:

IUserProfile profile = ClientContext.CurrentUser.Profile;
profile["CalendarViewSplitterDistance"] = 200;
ServerContext.UserManager.UpdateProfile(user);

where ServerContext is a SAO Singleton, ClienContext is a CAO and 
CurrentUser returns a reference to IUser which is also a CAO. 
IUserProfile is also a CAO.

The strange thing is, that when calling UpdateProfile() i don't get
any Exception at that point, just Dispose() is called on the main window 
an the i get invalid handle exception.

My question is: is it possible to pass a CAO reference back to server, 
or is it bad practice?

Thanks
Claus

6. Getting trouble when I am trying to create a ASP.net web application

7. How to access a CAO serverside, or - how to achieve CAO functionalities with a Singleton

8. C# Application is closed when creating a new instance of a Web Ser



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 94 guest