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

Top 5 Contributors of the Month
Post New Web Links

ObjectDisposedException from ActivityContext

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery
Hi All,

I am getting this error:

System.ObjectDisposedException: An ActivityContext can only be accessed within the scope of the function it was passed into.
Object name: 'System.Activities.ActivityContext'.
   at System.Activities.ActivityContext.ThrowIfDisposed()
   at System.Activities.ActivityContext.GetValue[T](LocationReference locationReference)
   at lambda_method(Closure , Resource )
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at System.Data.Linq.Table`1.DeleteAllOnSubmit[TSubEntity](IEnumerable`1 entities)
   at VirtualStorageActivityLibrary.Delete`1.Execute(CodeActivityContext context) in ... 
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

View Complete Post

More Related Resource Links

Retrieve the child ActivityContext from the Sequence activity

Hi all, I create my own sequence activity, which will report to DB. I would like to retrieve OutArgument from nested activity, but here is my problem - to access OutArgument I need child context. I would like to avoid adding to the children code responsible for raport to DB. Is this scenario (retrieve the child ActivityContext from the Sequence activity or something else) possible?

ServiceModel ObjectDisposedException

Every now and then I see this wcf error on the server hosting my per call wcf service (.net 4.0, net.tcp, IIS7, WAS):   TypeName: System.ObjectDisposedException TypeAssembly: mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message: Cannot access a disposed object. Object name: 'System.ServiceModel.Channels.ServerSessionPreambleConnectionReader+ServerFramingDuplexSessionChannel'. Source: System.ServiceModel TargetSite: Void ThrowIfDisposedOrNotOpen() StackTrace:    at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()    at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)    at System.ServiceModel.Dispatcher.DuplexChannelBinder.DuplexRequestContext.OnReply(Message message, TimeSpan timeout)    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout)    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc) ObjectName: System.ServiceModel.Channels.ServerSessionPreambleConnectionReader+ServerFramingDuplexSessionChannel     The corresponding client side error is this: TypeName: System.ServiceModel.CommunicationException TypeAssembly: System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message: The server did not provide

dispose StreamReader causes ObjectDisposedException on stream, dot net 4.0

Hi, We have some code that populates a stringbuilder from a MemoryStream, using a StreamReader's ReadToEnd() method.  Platform is dot net 4.0 on Windows 7 machine, VS2010.  Sample code: using (StreamReader reader = new StreamReader(stream, true)) { builder.Append(reader.ReadToEnd()); } At the "}" I can quickwatch the stream and it looks fine.  I know the "using" causes dispose to be called on the streamreader at this point.  Stepping past the "}", quickwatch on stream shows "threw an exception of type 'System.ObjectDisposedException'" for the capacity, length and position properties of stream.  This is all enclosed in a "using MemoryStream" block.  Exiting the outer using block, I'll get an exception "Cannot access a closed stream."  Does anyone know a workaround.  If there is a more appropriate forum to post this question please advise.  Any help is greatly appreciated.  Thank you.

MessageQueue + ObjectDisposedException + .Net 4.0

Hi,   I have implemented a dispose pattern in a class model which uses MessageQueue. My class A where all objects from class B must register to contains a Dictionary with MessageQueue objects. This works all fine. Objects from class B can be collect by GC and the dispose pattern, which let each object from class B sent a last message during disposing and so on. BUT! if the application shutdown the objects were collected in a strange order. For instance I can see in the debugger that the MessageQueue objects are disposed before the collection is disposed they contain to? And if the first MessageQueue object is disposed alle works fine (last message sent). but if the second MessageQueue object is disposed and will got to sent a last message I got the following exception:   {"Cannot access a disposed object.\r\nObject name: 'MQCacheableInfo'."}    at System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle()    at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, IntPtr transaction)    at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)    at System.Messaging.MessageQueue.Send(Object obj)    at Core.MQWriteQueue.SendMessage(XMLTelegram Telegram)    at Core.MQManager.SendTelegram

using objectdatasource with entity model leads to System.ObjectDisposedException


hi every body.

i my web application i used entity data model and imported some select stored procedures as functions (Add Function Import). so i used objectdatasource to call this functions and set their parameters to retrieve data. but when i run application the following exception shows:

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

C# SerialPort System.ObjectDisposedException, safe handle has been closed in System.DLL


I have an application in which at start up I need to do a port discovery process to determine whether instruments are attached to the end of any number of PC com ports. These com ports could be Bluetooth enumerated or, using FTDI USB to serial line convertor drivers, a USB connection. At start up I determine which ports are being used for this session by interogating all the ports stored in a list. I do this by opeing the port and then using a synchronous write and read (using timeouts of 500ms). I put try and catch around the port open to capture the case where the port has been disconnected (USB) or is not currently accessible (Bluetooth) and create a list of instrument objects each of which will have its own serial port object. Before going into normal mode I close the ports. So in essence this is

foreach(string portname in portstouselist)

    if open port success

        if writeline(Instrument?) success

            if Readline success

                 add instrument found and associated port to list

       close port

Normal running operates something like a data logger so I open each of the ports to which I have an instrument connected and start an asynchronous read with an associated data received event handler and infinite time out.

It is possible that the user connections could change during the application run.

System.ObjectDisposedException: Cannot access a disposed object.Object name: 'MQCacheableInfo'.



I am using MSMQ concept in my .Net windows service application. So, i got below mentioned error and messages are moved to UnHandled queue. If i process manually then message has been processed well. So, this issue we got quite common on my production environment. I would like to know whether can we fix this issue.

Exception Message:

2010-10-05 01:37:03,687 [Handler.1] WARN  HandlerService.CWorkerThread - Couldn't process message

System.ObjectDisposedException: Cannot access a disposed object.Object name: 'MQCacheableInfo'.

   at System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle()

   at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, IntPtr transaction)

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