Dave's Technophorical Times

A blog about Microsoft's Technologies!
SharePoint :: MVC :: ASP.NET :: IIS :: SQL Server :: Visual Studio :: MS Access

I deployed a SharePoint feature that has an Event Receiver and ran into this error when trying to update the Today Column during a nightly batch run. The Error occured on random Document Libray items. So I did some research and found out that I needed to update the Event Receiver to run as Synchonous when Updating items. This solved the problem! By default Event Receivers run Asynchrounsly, which is not always ideal, especially in this situation.

To fix this problem just update the Element.xml file for the Event Receiver in question for the event type (Updating) you want to run as Synchronous as follows. Then redeploy. Be sure to Deactivate and Activate the site feature once it has been redeployed since it might not be used everywhere.

<Synchronization>Synchronous</Synchronization> under Elements -> Receivers -> Receiver tag

Also in my nightly batch job I used the following code to disable Events when Updating... The Using Code is further down the page.

//Disables Events when updating
using (var scope = new DisabledItemEventsScope())
{
SPList list = oWebsite.Lists["Code Rules"];
//This must be switched on, otherwise the Update method will throw an exception.
collWebsite[i].AllowUnsafeUpdates = true;

for (int k = list.Items.Count - 1; k >= 0; k--)
{
SPListItem item = list.Items[k];
//This only Works if the List Item was manually Updated before using a column called Today.
item.Properties["Today"] = DateTime.Now.Date.ToString(CultureInfo.InvariantCulture);

//SystemUpdate Updates without changing the Modified Time OR Modified By and DOES NOT make a New Version!
item.SystemUpdate(false);
}
collWebsite[i].AllowUnsafeUpdates = false;
}

        #region DisabledItemEventsScope
        /// <summary>
        /// Disabled item events scope
        /// </summary>
        /// <see cref="https://adrianhenke.wordpress.com/2010/01/29/disable-item-events-firing-during-item-update/"/>
        class DisabledItemEventsScope : SPItemEventReceiver, IDisposable
        {
            bool oldValue;

            public DisabledItemEventsScope()
            {
                this.oldValue = base.EventFiringEnabled;
                base.EventFiringEnabled = false;
            }

            #region IDisposable Members

            public void Dispose()
            {
                base.EventFiringEnabled = oldValue;
            }

            #endregion
        }
        #endregion DisabledItemEventsScope

Good Luck!



One of our Clients were experiencing an issue while Opening one of the SharePoint 2010 Lists in Access. They were essentially Clicking on one of the links “Open in Access” from List’s Ribbon that would result in the following error.

“Export to database failed. To export a list, you must have a Microsoft SharePoint Foundation-compatible application.” To resolve this Download and Install the below hotfix for 32-bit Office and then restart your computer.

http://support2.microsoft.com/hotfix/KBHotfix.aspx?kbnum=2553170&kbln=en-US  



In the event logs, I found out, that I have errors in system logs:

  • Event Id: 7031, 7034;
  • source: Service Control Manager;
  • details: The SharePoint 2010 User Code Host service terminated unexpectedly.

I found out, that service account that was running Sandbox code service needs to have access to performance counters on the server. So what you need to do is pretty simple, you need to grant service account access to counters and you can do it by adding service account as a member of local group Performace Monitor Users in Server Manger.



Thanks to https://sajiviswam.wordpress.com/2011/04/15/the-machine-default-permission-settings-do-not-grant-local-activation-permission-for-the-com-server-application-with-clsid-000c101c-0000-0000-c000-000000000046-sharepoint-2010/

This error is being logged into the System event logs in Event Viewer due to inadequate permission for the farm admin account on the DCOM component 000C101C-0000-0000-C000-000000000046. In order to change the permission settings, perform the following steps.

  1. Open Component Service by clicking Start > Administrative Tools > Component Services.
  2. Navigate and expand the node Component Services > Computers > My Computer > DCOM Config.
  3. Right Click the sub node “000C101C-0000-0000-C000-000000000046” and select “Properties”.
  4. On the Properties dialog box, select Security tab. In most cases you will notice that the settings are grayed out. This is because the logged in user doesn’t have enough permissions on this component to change the settings. In order to provide this permissions, perform the steps described in next section “Change Component Service Owner and Permission”. You may need to restart the server after doing this.
  5. Once you set up the permission mentioned in previous step, in the Launch and Activation Permissions section in Security tab, select Customize option and click Edit.
  6. In the popup window, add the farm admin user account and check Local Launch and Local Activation permissions.
  7. Restart IIS and SP Timer. If possible, restart the server itself.

Change Component Service Owner and Permission

In the DCOM Config dialog box, you noticed that the settings are grayed out. In order to enable those settings, perform the following registry modification.

  1. Open Registry Editor by typing “regedit.exe” in Start > Run.
  2. Navigate and select the key “[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{000C101C-0000-0000-C000-000000000046}]”
  3. Right click and select Permissions.
  4. In the popup windows, click Advanced.
  5. In the Advanced Security Settings windows, select Owner tab and change the owner to Administrators. Click OK to close the window.
  6. In the Permissions screen, select Administrators and check Full Control. Click OK to close the screen.
  7. Close the registry editor.


From this guys site: http://www.mysharepointadventures.com/2012/11/removing-references-to-old-unused-databases-in-sharepoint-2010/

Over time, as you create / remove service applications, there is a tendency for SharePoint to retain a list of databases that are no longer in use but still referenced in the SharePoint Config database. If you try to remove the database on the SQL server without first removing it from SharePoint, you will get an event logged periodically on your SharePoint Web Front End about being unable to find / access the missing database.

Solution

To remove the orphan databases / databases that are no longer in use.

Run SharePoint Management Shell

Run the command

Get-SPDatabase | fl name,id

Locate the database you wish to remove and copy its ID.
Run the command

$db = Get-SPDatabase (id)
$db.Delete()

Now type Get-SPDatabase again, you should see that the database(s) have been removed.



From this guys great Blog! http://blogs.technet.com/b/meamcs/archive/2012/10/23/renaming-sharepoint-2010-search-service-database-name.aspx

In this post I’m planning to walkthrough the practice of changing the SharePoint 2010 Search Service Database names as you might need it in the following scenarios:

  • Replacing the Search Service Application Databases Names that Includes GUID’s to a friendlier name.
  • The Database Admin in the Organization is planning to change the naming convention of all the Databases names in the Data Center.
  • If you are planning to move from one Farm to another that has a different Naming Convention.

You have many options to do this practice as shown in the below figure, but in this post I will walkthrough the preferred steps only to make it simple and clear:

 

 

Renaming Property & Crawl DBs using Central Administration:

Verify that the user account that is performing the procedure is a member of the Farm Administrators SharePoint group.

  1. In Central Administration, click Application Management.
  2. On the Application Management page, click Manage service applications.
  3. Click the name of the Search Service Application.
  4. On the Search Administration page, click Modify.
  5. On the Manage Search Topology page, the following three databases are listed: Administration, Crawl, and Property. You can point to renamed or moved Crawl or Property databases by using this procedure.
  6. Click the database that you want to change, and then click Edit Properties.
  7. In the Database Server text box, type the new server location if there is one; in the Database Name text box, type the new name for the database; and then click OK.
  8. On the Manage Search Topology page, click Apply Topology Changes.

 

Notes:

  • You cannot point to a renamed or moved Search Administration database by using Central Administration.
  • It might take several minutes for the changes to take effect.

 

Renaming Search Service Application Database using PowerShell:

Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  1. On the Start menu, click All Programs.
  2. Click Microsoft SharePoint 2010 Products.
  3. Click SharePoint 2010 Management Shell.
  4. At the Windows PowerShell command prompt, type the following commands:
    1.  
      • Point the Search Administration database to its new name or location.
$searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "<NewDbName>" -DatabaseServer "<NewServerName>" 

 

Where:

  1.  
    1.  
      •  
        • <NewDbName> is the name of the renamed database
      •  
        • <NewServerName> is the new database location
  2. Monitor whether the search instances have finished re-provisioning.
Do {write-host -NoNewline .;Sleep 10; $searchInstance = Get-SPEnterpriseSearchServiceInstance -Local} while ($searchInstance.Status -ne "Online")

 

Additional References:

  1. Rename FAST Search for SharePoint 2010 Databases
  2. Rename or  Move Service Application
  3. Change database (FAST Search Server 2010 for SharePoint)


I ran into a problem recently when looking up the Created By and Modified By fields for an List Item so I caould display it on an Application Page. When I opened the page it worked fine, however when a user with less privilages opened it they got an error laie this "Value does not fall within the expected range".

This is what I found and I have no idea why this was the solution BUT it worked for me.

http://blog.vanmeeuwen-online.nl/2012/07/value-does-not-fall-within-expected.html

Solution(s):
It seems there can be several causes.
1). Use of invalid field name. You need to use the internal field name! However, that was not the case in my situation.
2). Change the List View Lookup Threshold value of the web application. Default value is 8, I changed it to 20 and big surprise: it worked! Thanks to this post.
Note: My item has some lookup fields some of which some have more than 8 items.
Little conclusion: So it seems that when using (one of) the system admin accounts, this list view lookup threshold is ignored in one way. By using non-system admin accounts, it can be a show stopper.
Steps to edit this value:

  • Go to Central Administration > Application Management > Manage web applications
  • Select the appropriate web application (in my case the SharePoint - 80)
  • In the ribbon bar, select General Settings > Resourse Throttling
  • Search for the List View Lookup Threshold and change the value to 20.


I recently needed to change the Title of an Application Page in SharePoint 2010 from code behind. This is how I did it in Page_Load...

So the sequence goes:

  1. Get a reference to the appropriate Content Placeholder
  2. Clear out anything that SharePoint might have put in it already
  3. Put your content in.

Or, in C#:

ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder) Page.Master.FindControl("PlaceHolderPageTitle");

contentPlaceHolder.Controls.Clear();

LiteralControl literalControl = new LiteralControl();

literalControl.Text = "Your text goes here";

contentPlaceHolder.Controls.Add(literalControl);



It is very very simple to avoid p page refresh in post-back . To get this we just have to use ASP "Update Panel Control" it will not refresh the page again and again on post-back.


Here is an example.

In Default.aspx



<asp:UpdatePanel ID="pnlPageRefresh" runat="server">
        <ContentTemplate>
            <div>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                </asp:DropDownList>
                <br />
                <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"></asp:TextBox>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
                </asp:RadioButtonList>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
<div>
<asp:Button ID="btnSave" runat="server" Text="Button" />
</div>


After using this your page will not at all refresh again and again on post-back. Your code will work fine but refresh flickering will not occur.



What he said! Works 100%

http://get-spscripts.com/2011/06/removing-features-from-content-database.html?showComment=1409706064396#c8164895157536909785



The Blogger

Dave Stuart I'm a Developer with a passion for coding. I enjoy the challengers that come with the job! SharePoint is one of my expert areas along with .NET Web Development with MVC and good old MS Access VBA coding. I Blog so that I can remember how I did that way back when; PLUS all this stuff is searchable! I constantly study and run my own business, Dafran Inc. I have passed 22 Microsoft Exams since 1998 when I first jumped on the treadmill of knowledge. I hope that you enjoy this Blog as much as I enjoy updating it. All the very best from Calgary, Alberta, Canada. contact me at linkedin @ dafran.ca

Calendar

<<  March 2017  >>
MoTuWeThFrSaSu
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Sign in