.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

InvalidOperationException in SynchronizationContextSwitcher.Undo

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :.NET Framework

I can't repro this on my machine, but on a customers machine my app throws the following exception:



The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).


   at System.Threading.SynchronizationContextSwitcher.Undo()

   at System.Threading.ExecutionContextSwitcher.Undo()

   at System.Threading.ExecutionContext.runFinallyCode(Object userData, Boolean exceptionThrown)

View Complete Post

More Related Resource Links

Team System: Work Items and Undo Support


Add support for work items to the Team Foundation Server version control add-in.

Brian A. Randell

MSDN Magazine September 2007

{ End Bracket }: To Confirm is Useless, to Undo Divine


The common user interface technique of confirmation, popping a dialog box into the user's face and asking, "Are you really REALLY sure you want to do that?" is evil. It's unfriendly, it's distracting, and it's completely ineffective.

David S. Platt

MSDN Magazine March 2005

Disable VS2005 Undo?


Does anyone know if there is a way to disable the Undo feature within VS2005?  I searched through the options but nothing jumped out at me.


System.InvalidOperationException: Invalid attempt to read when no data is present.


Invalid attempt to read when no data is present.

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.InvalidOperationException: Invalid attempt to read when no data is present.

Source Error: 

Line 53:             if (reader.HasRows)
Line 54:             {
Line 55:                 Response.Write(reader.GetString(0));

Here is my code:

VS 2010 Designer InvalidOperationException after using Blend 4 VSM

Working on an WPF 4 app today and noticed the VS 2010 Designer won't load after using Blend 4 Visual State Manager. Basic info that I did. 1. Had a Button.  Would display in both VS10 Designer and Blend 4. 2. In Blend 4, I right clicked Button -> Edit Template -> Create Empty. 3. Added ContentPresenter to Grid. 4. Back in Window.xaml, added Image to Button's ContentPresenter.  Still works in both VS10 and Blend 4. 5. In Blend 4, went back to Edit Template and modified some of the States.     - Disabled: Grid Opacity 50%     - MouseOver: Grid Scale X/Y to 1.1     - Pressed: Grid Angle 15. 6. Save and go back to VS10, the designer won't load.  Get the Yellow bar at top stating something like... InvalidOperationException was thrown on "button": Property does not point to a DependencyObject in path...... The button now has an X with red circle in it. Is this a know issue?  Is there a fix? It still works in Blend 4 and I can run the WPF app in both VS10 and Blend 4. Thanks in advance.

BIDS undo/redo buttons

In MS Visual Studio 2008 on Windows Server 2008 or BIDS my undo / redo buttons are grayed out when I am editing an SSIS package. I would like to know if there is a way to enable this. I have searched and searched everything looks retardedly complicated to get this working. Help? Anyone, anyone... Microsoft are you there?

System.InvalidOperationException: Instance operation is not valid on workflow runtime thread

Am getting the exception related in the title of this article when using the StateMachineWorkflowInstance object to arbitarily set state in my workflow code; and am unsure why.  The code follows below:   500     Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus   501    502    506         Dim smwi As StateMachineWorkflowInstance = New StateMachineWorkflowInstance(StaticWFRuntime.LocalRuntime, Me.WorkflowInstanceId)   511    512         'set workflow-wide database connection string   513         _connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString   518    519         Utility.LogEnabled()   520    521         Utility.FoaeaLogger.WriteEntry("Processing TracingApplication.Execute()....", EventLogEntryType.Information)   522         If StaticWFRuntime.LocalRuntime Is Nothing OrElse StaticWFRuntime.LocalRuntime.IsStarted = False Then   523             Utility.FoaeaLogger.WriteEntry("No static RuntimeService object exists!", EventLogEntryType.Warning)   524         End If   525    526         Return MyBase.Execute(executionContext)   527    528     End Function   796     Private Sub gotoState2_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)   797    798        

InvalidOperationException error with jquery call to webmethod

Hi, I'm having an issue which results in returning the following from XHR requests to an webmethod on my form. {"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}Simplified form Code is as follows. [WebMethod]        public string LoadContact()        {            return string.Format("Hello From Server");        }I'm using JQuery to make the call: $.ajax({            type: "POST",            url: "SYS_AjaxResearch.aspx/LoadContact",            data: "{}",            contentType: "application/json; charset=utf-8",            dataType: "json",            success: function(msg) {                $("#topPanel").text(msg.d.LoadContact);   

System.InvalidOperationException: Timeout expired.

Hi I am getting the following error on my page:System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at _default.commentCount(Int32 ArtID) at ASP.default_aspx.__DataBind__control4(Object sender, EventArgs e)....I thought I had closed all the connections in my code:Imports System.Data Imports System.Data.SQLClient Partial Class _default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load commentDisplay() End Sub Sub commentDisplay() Dim pageno As Integer = Request.QueryString("page") Dim MyConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("nbb").ConnectionString) Dim MyDataAdapter As SqlDataAdapter MyDataAdapter = New SqlDataAdapter("art_getHomepage", MyConnection) MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

Farm, SPWebApplication.Lookup, System.InvalidOperationException

Dear all,   I have a piece of code that works well on a standalone SharePoint installation:   public void SetPeoplePickerProperty(string webAppUrl) { // elevate permissions to allow setting of property. SPSecurity.RunWithElevatedPrivileges(delegate() { System.Uri srvrUri = new System.Uri(webAppUrl); SPWebApplication webApp = SPWebApplication.Lookup(srvrUri); if (!webApp.PeoplePickerSettings.OnlySearchWithinSiteCollection) { webApp.PeoplePickerSettings.OnlySearchWithinSiteCollection = true; webApp.Update(); } }); }   When I deploy it to a server farm, I get the following error: System.InvalidOperationException: This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products and Technologies Configuration Wizard, located on the Start menu in Administrative Tools.   at Microsoft.SharePoint.Administration.SPWebApplication.Lookup(Uri requestUri) The user running the query is farm administrator. It has the necessary access to the configuration database. The server running the code is joined to the farm.   Ideas anyone?   Thanks,   Tore.

System.InvalidOperationException: The 'IBMDA400.DataSource.1' provider is not registered on the lo

I am run the ETL package through the SQL Server Agent, the job fails with the error message "System.InvalidOperationException: The 'IBMDA400.DataSource.1' provider is not registered on the local machine.". But when i run trough the UI is runs fine. I am uisng OLE DB driver to the connect to AS400. can you please tekk ne where a im going wrong.   The  log file entery is as follows    OnProgress,DCMS2100,RBGDC01\SMTSQL_service,LMS_ORDER_HEADER REFRESH,{78FE47C8-9539-4A20-8FC7-BC790204C2F0},{AF7E99E5-653C-4BF5-B5A1-B1E7CE2AEE9E},31/07/2006 19:57:30,31/07/2006 19:57:30,0,0x,ValidatingOnProgress,DCMS2100,RBGDC01\SMTSQL_service,LMS_ORDER_HEADER REFRESH,{78FE47C8-9539-4A20-8FC7-BC790204C2F0},{AF7E99E5-653C-4BF5-B5A1-B1E7CE2AEE9E},31/07/2006 19:57:30,31/07/2006 19:57:30,50,0x,ValidatingOnError,DCMS2100,RBGDC01\SMTSQL_service,LMS_ORDER_HEADER REFRESH,{78FE47C8-9539-4A20-8FC7-BC790204C2F0},{AF7E99E5-653C-4BF5-B5A1-B1E7CE2AEE9E},31/07/2006 19:57:31,31/07/2006 19:57:31,-1073450910,0x,System.InvalidOperationException: The 'IBMDA400.DataSource.1' provider is not registered on the local machine.   at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)   at System.Data.OleDb.OleDbConnectionFactory.Cr

Error connecting to undo manager of source file?

When I run my project I get an error that says: Error connecting to undo manager of source file: path to my project/myproject/contact.aspx.designer.cs".How do I correct this?

Receiving error when saving site as template: [InvalidOperationException: Error generating solution

I am getting the following error when saving a site as a template (just this specific site is having this issue - other sites in collection successfully save as template): [InvalidOperationException: Error generating solution files in temporary directory.] Microsoft.SharePoint.SPSolutionExporter.ExportWebAsSolution() +26053165 Microsoft.SharePoint.SPSolutionExporter.ExportWebToGallery(SPWeb web, String solutionFileName, String title, String description, ExportMode exportMode, Boolean includeContent, String workflowTemplateName, String destinationListUrl) +1778 Microsoft.SharePoint.SPSolutionExporter.ExportWebToGallery(SPWeb web, String solutionFileName, String title, String description, ExportMode exportMode, Boolean includeContent) +44 Microsoft.SharePoint.ApplicationPages.SaveAsTemplatePage.BtnSaveAsTemplate_Click(Object sender, EventArgs e) +331 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981 I'm thinking it may have something to do with permissions, but other sites can save as a template. Also, it does not specify

How to undo any change done on checked tree view control

Frnds,   I have Check boxed tree view control on a popup control.   Two button also there, 1) Save   2) Cancel.   On cancel I am hiding the pop-up control. But if any change I have mad on tree view (Check or Uncheck) will be there if I am open it again.    So I need to undo any change done on tree view if I clicked cancel button.     Can any one help me on this?

Undo After Adding Activity Which Causes Designer Resize

Hi, I created a very simple test application which consists of a Toolbox and a Workflow Designer.  In the toolbox, I only added a "Terminate" activity: public MainWindow() { InitializeComponent(); new System.Activities.Core.Presentation.DesignerMetadata().Register(); _workflowDesigner = new WorkflowDesigner(); Grid.SetColumn(_workflowDesigner.View, 1); _workflowDesigner.Load(new System.Activities.Statements.Flowchart()); LayoutGrid.Children.Add(_workflowDesigner.View); _toolbox = new ToolboxControl(); ToolboxCategory undoTestCategory= new ToolboxCategory("Undo Test"); ToolboxItemWrapper terminateTool = new ToolboxItemWrapper(typeof(System.Activities.Statements.TerminateWorkflow), "Terminate"); undoTestCategory.Add(terminateTool); _toolbox.Categories.Add(undoTestCategory); Grid.SetColumn(_toolbox, 0); LayoutGrid.Children.Add(_toolbox); } When I drag/drop the "Terminate" to the middle of the designer, I can press Ctrl-Z once to undo it (i.e. remove it from the designer).  However, if I drop it at the edge of the designer which forces a resize/expansion of the designer, it takes 4 Ctrl-Zs to undo it.  Is there a way around this?  Also, is there an easy way in the debugger to see the undo stack? Thank you.  

InvalidOperationException using auto-generated class

I'm getting the below exception while trying to create an instance of  XmlSerializer using the class generated from XsdObjecGen. Any ideas on what may be causing this? System.InvalidOperationException: There was an error reflecting field '__ApplicationArea'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.ApplicationArea'. ---> System.InvalidOperationException: There was an error reflecting field '__Sender'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.Sender'. ---> System.InvalidOperationException: There was an error reflecting field '__LogicalID'. ---> System.InvalidOperationException: There was an error reflecting type 'ConsoleApplication2.Oagis.LogicalID'. ---> System.InvalidOperationException: There was an error reflecting field '__Value'. ---> System.InvalidOperationException: There was an error reflecting type 'System.String'. ---> System.InvalidOperationException: Value 'String' cannot be used for the XmlElementAttribute.DataType property. The datatype 'http://www.w3.org/2001/XMLSchema:String' is missing. The code in question from the exception.. '*********************** XmlText field *********************** <XmlText(DataType:="String"), _ EditorBrowsable(EditorBrowsableState.Advance

Word Interop - System.InvalidOperationException in System.Windows.Forms.dll



Microsoft Visual Studio 2005 Version 8.0.50727.42 

Microsoft .NET Framework Version 2.0.50727

Word 2003 Interop


I am trying to recreate the "AmbiguousMember" example from p. 31 of Whitechapel's "MS .NET Development for MS Office" using VB instead of VC#.

This involves implementing an event handler for the Word Quit event. In the event handler, I need to toggle the Enabled state of two buttons. This causes the following error:

A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll

The code behind the Form1 form is shown below. Form1 has two buttons: Button1 "Run Word"; Button2 "Quit Word". The event handler is intended to clean up if the user quits the Word application, and reset the buttons.

A net s

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