.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

Farm, SPWebApplication.Lookup, System.InvalidOperationException

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :SharePoint
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.

View Complete Post

More Related Resource Links

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:

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        

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

Directory lookup for the file failed with the operating system error 5

Hi I have a Windows desktop application that uses a SQLServer Express database.  The database files are downloaded from my website, followed by the application download (written in VBE).  The first procedure is to attach the database to the SQLServer instance from within the application. I have two test machines one runs Windows XP x84, the other Windows 7 x64.  I never have issues on attaching the database files in my test envirnoment but twice now other people downloading have got the following error System.Data.Sqlclient.sqlexception (ox 80131904) Directory lookup for the file C:\Documtents and Settings\Administrator\Desktop\Tem1.mdf failed with the operating system error 5 (failed to retrieve text for this error. Reason 1815) changed database context to 'master'. I'm not sure what the problem is and therefore how to correct the issue.  I attach the database in code using the create statement e.g. cmd7.CommandText = "USE Master CREATE DATABASE Tem1 ON PRIMARY (FILENAME = '" & DBFullPath & "') LOG ON (FILENAME = '" & DbLogPath & "') FOR ATTACH" Any help or suggestions would be very much appreciated. Chris    

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

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

System.InvalidOperationException: Internal .Net Framework Data Provider error 12.



I have created an application in which there are few forms. Each form has fields which are linked to a backend table/tables. My application is supposed to be accessed by multiple users concurrently. I ran a test where I created a class file in windows application and i ran a for loop in it to call the url of my application. I wanted to test the effect of firing around 200 queries to my query engine.

The test code is :

namespace MachineGun


static class Program


/// <summary>

/// The main entry point for the application.

/// </summary>


SPWebApplication, This operation can be performed only on a computer that is joined to a server farm



We are trying to migrate a console program (C#) from Moss 2007 to SP 2010.

One of the functions in the program has to loop thru several web apps/site colls/sites/lists to trim permissions and uses this sentence to get a reference to the web app:

- SPWebApplication webApplication = SPWebApplication.Lookup(serverUri);

In MOSS 2007 it works but in SP 2010 we see this error message:

"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

ReloadTrackingProfiles: System.InvalidOperationException: TrackingListener for instance %0 is not in



I am hosting Workflows (dll based) in a web application. I created my own TrackingService and my own TrackingChannel (code below). When starting a workflow, everything works fine, all events are tracked. After re-building my solution, workflows, that were running before, do not track anything anymore (although they continue execution). Info: On every build, the build number of all assemblies is increased by default.

I tried to reload the tracking profiles after loading workflows (using workflow.ReloadTrackingProfiles();), but this leads to the error above. 

What am I doing wrong?




Here is the code for the tracking service:

    public class EnablerWFTracking : TrackingService {


        private TrackingProfile profile;


        #region Constructor

        public EnablerWFTracking()

            : base() {

            profile = this.CreateTrackingProfile();




        #region CreateTrackingProfile


ServerVersion = 'Conn.ServerVersion' threw an exception of type 'System.InvalidOperationException



I have a web service  which tries to connect to the SQL server.

It uses Integrated security = true.

I get the Conn.ServerVersion threw an exception of  type System.InvalidOperationException as soon as the connection object is instatiated.

Any leads.


System.InvalidOperationException: Response is not well-formed XML. ---> System.Xml.XmlException: DTD


Can any one help me out of this.

System.InvalidOperationException: Response is not well-formed XML. ---> System.Xml.XmlException: DTD must be defined before the document root element. Line 2, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res) at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at Microsoft.Web.Services2.Xml.XmlSkipDTDReader.Read() at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at Microsoft.Web.Services2.SoapEnvelope.Load(Stream stream) at Microsoft.Web.Services2.Messaging.SoapPlainFormatter.Microsoft.Web.Services2.Messaging.ISoapFormatter.Deserialize(Stream stream) at Microsoft.Web.Services2.InputStream.GetRawContent() at Microsoft.Web.Services2.InputStream.set_Position(Int64 value) at Microsoft.Web.Services2.WebServicesExtension.BeforeDeserializeClient(SoapClientMessage message) at Microsoft.Web.Services2.WebServicesExtension.BeforeDeserialize(SoapMessage message) at Microsoft.Web.Services2.WebServicesE

InvalidOperationException: 'System.Windows.Documents.Hyperlink' is not a Visual or Visual3D


I have a simple TreeView with a template containing a TextBlock with an inline Hyperlink. Whenever I use the keyboard to navigate the tree to this templated item, I get this:


'System.Windows.Documents.Hyperlink' is not a Visual or Visual3D.
   at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
   at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
   at System.Windows.Controls.TreeViewItem.AllowHandleKeyEvent(FocusNavigationDirection direction)
   at System.Windows.Controls.TreeViewItem.HandleDownKey()
   at System.Windows.Controls.TreeViewItem.OnKeyDown(KeyEventArgs e)
   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.

help me out......System.InvalidOperationException: RegisterDataItem can only be called during an asy


hiiii i m getting an exception while i m selecting date...

System.InvalidOperationException: RegisterDataItem can only be called during an async postback.

[InvalidOperationException: RegisterDataItem can only be called during an async postback.]
   System.Web.UI.PageRequestManager.RegisterDataItem(Control control, String dataItem, Boolean isJsonSerialized) +521917
   AjaxControlToolkit.PopupControlExtender.Close(String result) in d:\hg\act\Server\AjaxControlToolkit\PopupControl\PopupControlExtender.cs:123
   AjaxControlToolkit.PopupControlExtender.Page_PreRender(Object sender, EventArgs e) in d:\hg\act\Server\AjaxControlToolkit\PopupControl\PopupControlExtender.cs:113
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnPreRender(EventArgs e) +8864486
   System.Web.UI.Control.PreRenderRecursiveInternal() +103
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496

asp code
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">               
                <br />

System Development Life Cycle

The Systems Development Life Cycle (SDLC) is a conceptual model used in project management that describes the stages involved in an information system development project from an initial feasibility study through maintenance of the completed application. Various SDLC methodologies have been developed to guide the processes involved including the waterfall model (the original SDLC method), rapid application development (RAD), joint application development (JAD), the fountain model and the spiral model. Mostly, several models are combined into some sort of hybrid methodology

The Agile System Development Life Cycle (SDLC)

The goal of this article is to describe the agile system development life cycle (SDLC), putting it in context from what you may have heard about within the agile community and more importantly within the context of your overall IT efforts.

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.



hello i have the following problem

i have upload my content to hosting server but i get the following error

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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:

[SecurityException: Request for the permission of typ
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