.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Stream object is inaccessible after returning from remote layer through remoting -

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

In my export function I am returning the System.IO.Stream object from remote layer through remoting. But getting the stream object it becomes inaccessible when I called the remoting layer with integrated authentication. It is giving me The remote server returned an error: (401) Unauthorized exception even I access its CanRead or CanWrite property. This is happening only in case of integrated authentication. For without any authentication its working fine.

 Dim ostream As System.IO.Stream
                        oWriter.WriteLine(Now & " - Before calling GetExportData")
                        ostream = oExport.GetExportData(dsGrid, intDateType, repPage.m_strFromDate, repPage.m_strToDate, repPage.m_strProcessStatus, repPage.m_strLocation, repPage.m_strDiseaseOrGrouping, repPage.m_strDiseaseOrGroupingDR, repPage

View Complete Post

More Related Resource Links

Remoting: Managing the Lifetime of Remote .NET Objects with Leasing and Sponsorship


Leasing and sponsorship is the solution for managing the lifecycle of a remote object in .NET. Each object has a lease that prevents the local garbage collector from destroying it, and most distributed applications rely upon leasing. There are several ways in which objects and clients can extend the lease, including dedicated sponsor objects. In this article, the author explains leasing, shows how to configure it, and how it relates to the various remoting activation models. He then discusses design guidelines and options, along with their impact on throughput and performance. Additionally, he introduces a helper class used to automate the management of lease sponsors.

Juval Lowy

MSDN Magazine December 2003

Remoting from WebService throws: An existing connection was forcibly closed by the remote host

Hello everyone, I have a problem with using .NET remoting from webservice. When using remoting from console application, there is no problem. I suppose problem is somewhere in IIS. My system is Windows Vista. Thank you for any help. Best regards, Jozef

Proxy failed to create remote object on the server

Hi, I am using .net remoting for inter-process communication between two processes on the same machine 1.   The first process is one of the Office application: Ecxel /   Word /   PP 2.   The other process is another application that interacts with one of the above. For that it needs office application object. For example: Excel The solution is comprised with 3 projects: Project #1: The remote object is a simple Called RemoteOfficeApplication – that simply wraps the required application object (Word / Excel / PP).   Project #2: The Server is a simple Office add-in, written with a Visual Studio Extensibility -> Shared project. This add-in is instantiated whenever Excel is lunched. This project reference project #1. Code: var channel = new TcpChannel (5003); ChannelServices.RegisterChannel(channel,true ); RemotingConfiguration.RegisterWellKnownServiceType( typeof (RemoteOfficeApplication.RemoteOfficeApplication ), “AppObj”, WellKnownObjectMode .Singleton);   Project #3: The Client is the process that requires the application object. This project also reference project #1. Code:   //Get Remote object proxy object remoteAppObject = Activator.GetObject(typeof(RemoteOfficeApplication.RemoteOfficeApplication), “tcp://localhost:5003/AppObj" ); //Cast the proxy var r

.NET Remoting Problem with Sponsor Renewal on CAO (Client Activated Object) Architecture

I have figured out a strange behaviour when using Client Activated Sponsorship and hope to get a hint from somebody who already got in touch with similar problems. The case is as follows: An Application is used by a server and a client. Both use (or try to use) the same objects after a user login. A lease of a session object on the server (serverSession) is initialised correctly with all of its regular remoting values in the lease for InitialLeaseTime (10) SponsorshipTimeout (5) RenewOnCallTime (10) In order to test the behaviour the values are set to seconds. It is easier to check the log every few seconds, than to wait some minutes until the Sponsorship Renewal call. If a client performs a login, the lease is according to its logged in state renewed each 10 seconds (or whatever the value is set to). So no problem so far. The lease will be alive as long as the client performs a logout, by the way it is used on a local network. Just compare the log (the renewal is firing every 10 seconds as expected): 2010-02-17 10:29:40.4338 Info Log5 SponsorObject:Renewal() 2010-02-17 10:29:50.4308 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:00.4328 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:10.4298 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:20.4318 Info Log5 SponsorObject:Renewal() 2010-02-17 10:30:30.4288 Info Log5 SponsorObject:Renewal() As soon as

trapping connection to remote object


I have a .net Remoting application.   I would like to do some tracking when connections are made.   Is there a way to interrogate connections being made to my remote object?

I have a singleton object, running as a service.   Basically when a ui connects I want to report back the state, and any pending messages.   So by looking at the connections I can keep a ptr to the next group of messages based on the client that connected.

Any insight into this would be a big help.



WCF returns private members of the object instead of returning the Public members



I am  using WCF to return a serialized custom object to a web page which access the WCF using a script manager. The problem here is the object returned all the private members instead of the public members although the private members are marked private.

The flow behind this: the asp.net  web site stores the object in SQL State session; all the classes in the object are marked serialized as it is stored in SQL State Session. All the public properties in the classes are marked as <DataMember>. When trying to access this object from the client it lists down all the private members of the class instead of listing the public members.

Please advice!

Many Thanks




Service returning Object fails when object is complex class


Hi. I have created a WPF client and a self-hosted WCF Service based on an interface, in wich alle methods returns a standard response class. An example of one such method definition is:

Response CreateAccount(AccountCreationParams accountParams);


The response object is defined as:



public class Response



public string ResponseText;


public bool CompletedSuccesfully;



Hide inaccessible databases from object Explorer


Hi All

Does anybody know if it is possible to hide databases in the object explorer which the user doesn' t have access too

I currently connect to a shared hosting solution and can see all of the databases on the server approx 80 + and it becomes a bit of chore to find my 3 databases in this growing list .



Windows 2008 Server: Authentication failed because the remote party has closed the transport stream


Hi, I am trying to use TLS to connect to the Windows 2008 Server from windows XP, I set Authentication=False.

It throws the below authentication exception when connected to WIN 2008 Server with SP2, where as it used to work fine with WIN 2003:

System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Below is the sample code.


protected Stream stream;

IPEndPoint ipe = new IPEndPoint(addr, port);

Socket socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);


socket .SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, options.keepAlive);
socket .LingerState = new LingerOption(options.lingerTime >= 0, options.lingerTime >= 0 ? options.lingerTime : 0);
socket .NoDelay = options.noDelay;

stream = new SslStream(stream, false, new RemoteCertificateValidationCallback(true), null);


I am using .Net 3.0 Frame work & VS 2005

Any help over here is highly appreciated.



HOWTO: using a remote COM+ object



using another IDE (SQLWindows/Unify) I created a COM-object containing some business logic. Now I want to access the methods of this COM-object using VS2010 and C#. I have the .dll and .tlb file for my COM object.

In my first try, I registered the DLL locally using regsvr32. I referenced the DLL from my C# client and can successfully call the methods in this COM object.

Now I want to install this COM object on a remote machine using the Component service. I know how to do the remote install. What I don't know is how to access the remote COM object with my C# client. From what I've found so far is, that I must create a new DLL from the .tlb file using tlbimp.exe. In my C# client for the remote com object  I need to reference this new DLL. But how do I create/activate the remote com object to call any method? Somehow I must specify the servers name or IP address. I found some code about how to call a remote com object using reflection but this thread says that this is only relevant when you don't have the .tlb

Am I right when I assume that as long as the interface of my COM object does not change, that I can install a new version on the server and the remote client will still work with the old DLL created with tlbimp. Or must I recreate this DLL with tlbimp every time?

I would be glad if someone can point me to s

Using IPC only channel getting Unable to cast object of type 'System.Runtime.Remoting.Identity' to


I have a remoting application that is using delegates to preform callbacks between processes. I found that if I don't use a TCP channel at all and only initialize an IPC channel that the callback delegates start throwing the following error after about a minute has passed.

From what little I could find on Google it seems to be a Lifetime Service management issue but all the classes that the delegates belong to return null from InitializeLifetimeService which should give the object an infinite lifetime.

With the TCP channel initialized the issue doesn't happen, but I would like it to use the IPC channel if all of the processes are on the local box.


Type:        System.InvalidCastException
Message:    Unable to cast object of type 'System.Runtime.Remoting.Identity' to type 'System.Runtime.Remoting.ServerIdentity'.
Stack Trace:   
Server stack trace:
   at System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)


Authentication failed as remote party has closed the transport stream



Hi All,

I am getting following message:


Message = " Authentication failed because the remote party has closed the transport stream."


NOTE: In my case client and Server both are on the same machine, so I passing the same values for machineName and serverName to the following method


public static void RunClient(string machineName, string serverName)


// Create a TCP/IP client socket.

// machineName is the host running the server application.

TcpClient client = new TcpClient(machineName, 443);


Raise Events in remoting object


Hello i m new to .Net Remoting and I have following scenario and don't know how to deal with event raised on service side and handled on client side.

My remote object starts controller and controller further starts scheduler

Scheduler is responsible for scanning all jobs in queue and adding more jobs in a queue.

Queue member raises an event which i want to handle on client side

Could anyone help me to get solution for this


Remoting, CAO, destruction of Object - How ?


This question is in reference to the article at


broker CAO using factory pattern.


I'm not able to get the destructor called for the CAO, unless the remoting server is stopped.

Is it because the object implemented using factory and the reference to the object becomes anonymous??


I have also tried for override the method "InitializeLifetimeService"


 public override object InitializeLifetimeService()
      ILease lease = (ILease)base.InitializeLifetimeService();
      if (lease.CurrentState == LeaseState.Initial)
        lease.InitialLeaseTime = TimeSpan.FromSeconds(1);
        lease.RenewOnCallTime = TimeSpan.FromSeconds(1);
        lease.SponsorshipTimeout = TimeSpan.FromSeconds(0);
      LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(1);
      LifetimeServices.LeaseTime = TimeSpan.FromSeconds(2);
      LifetimeServices.SponsorshipTimeout = TimeSpan.FromSeconds(2);

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

C# Object Oriented Programming

So far in C# Essentials we have looked at the basics of programming in C# such as variable types and flow control. Although it would be possible to write a functional program using these techniques, there is much more to becoming a proficient C# programmer. C# is, above all, an object oriented programming language and as such any C# programmer will be expected to create object-oriented applications using this language.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend