Showing posts with label SharePoint Configuration. Show all posts
Showing posts with label SharePoint Configuration. Show all posts

June 2, 2016

SharePoint 2013 - Unable to read Web.Config file in Event receiver

Introduction:
Generally, we use web.config file’s app settings section to keep configurable and application wide settings that an application requires in order to perform the task properly. This helps in easy maintenance and deployment of the application, because we can easily update the settings and verify without build and deployment.

Now we read the key value pairs from web.config file as follow:
ConfigurationManager.AppSettings[key]

I need to use these app settings in Item added Event receiver in SharePoint list. Though, the above code worked fine on local environment, but on production server, it gave exception.
"Object reference not set to an instance of an object"

In the Event receiver, the above code is unable to find and read the web.config app settings, you would've noticed that although code compiles and runs, this comes back null. Well, the very generic answer to why this is, is because the event handler isn't really running within the same context as a Web site that has direct access to the ConfigurationManager.

Approach/solution:
There is a simple solution for this issue, just change the approach of reading the web.config file.

Below is the method we have implemented to read the web.config file:
public static string GetAppSettingKeyValue(SPSite siteCollection, string key)
        {
            System.Configuration.Configuration config;
            if (string.IsNullOrEmpty(siteCollection.WebApplication.Name))
                throw new ApplicationException("Web application name is empty!");
            config = WebConfigurationManager.OpenWebConfiguration("/", siteCollection.WebApplication.Name);
            AppSettingsSection appSettings = config.AppSettings;
            if (appSettings == null)
                throw new ApplicationException("Web.config appSettings section cannot be found!");
            if (appSettings.Settings[key] == null || string.IsNullOrEmpty(appSettings.Settings[key].Value))
                throw new ApplicationException("Key value cannot be read from settings of appSettings. Make sure this key and its value exist!");
            return appSettings.Settings[key].Value;
        }


And then we just have to call the above method from event receiver’s events with necessary parameters to read the settings as below:
GetAppSettingKeyValue(new SPSite(properties.SiteId), key);

Here, first parameter is SPSite object and the second parameter is a app settings key, for which we need to read value from web.config file.

Thus all we need to do is, just change the approach of reading web.config file and we are done! Now, we can successfully read the app settings configuration.

If you have any questions you can reach out our SharePoint Consulting team here.

May 3, 2016

Web Application creation issue in SharePoint

Issue: Creating a Web Application from Central Admin sometimes continues to run forever and getting error message: "Please contact your System Administrator".


Resolution : Here are detailed steps to fix it.

1. Open IIS Manager.
2. Select correct Application Pool of Central Administration Site from “Application Pools”.
3. Right click and select Advanced Settings... and, look for “Shutdown Time Limits(seconds)".
4. Increase it to 1200. Note: Default value is 90 seconds
5. Click OK.
6. Do IISReset.
Finally, you should be able to create Web Application successfully without any issue.

If you have any questions you can reach out our SharePoint Consulting team here.

March 29, 2013

Create and Configure Visio Graphics Services

Visio Graphics Service Overview

The Visio Graphics Service is a Microsoft SharePoint Server 2010 service application that allows users to share and view Visio web drawings using Visio Services. Visio Graphics Services allows Visio Web drawings published in VDW format to be shared with other users who may not have Visio 2010 installed on their computers. VDW formats can be created only by Visio Professional 2010 or Visio Premium 2010. Standard Visio drawings (VSD files) are not rendered by Visio Services and require Visio to be viewed.
Microsoft Visio 2010 situates diagramming to an advance level with dynamic, data-driven visualization tools, and advanced Web sharing capability. It composes data from various sources, including Microsoft SharePoint Foundation Services list, Microsoft Office Excel workbook, Microsoft Office Access database, Microsoft SQL Server database, and other OLEDB or ODBC data source and presents it using vibrant graphics design. It facilitates SharePoint workflows creation and publication for instantaneous implementation.
The Visio Graphics Service is a SharePoint Server 2010 service application that enables dynamic viewing, refreshing, and sharing of data-driven Microsoft Visio 2010 diagrams through Visio Web Access Web part, Web part Connections, and Visio Services Mash-up API. This piece will provide high-level steps in consuming this service application.

Start a Visio Graphics Service

To start a Visio Graphics Service by using Central Administration
  • Verify that you have the following administrative credentials:
    • To start a Visio Graphics Service, You must be a member of the Farm Administrators group.
  • On the Central Administration Home page, in the System Settings section, click on the Manage services on server.
  • If Visio Graphics Service is shown Stopped then click on the Start.
  • After clicking on the Start, Visio Graphics Service status is shown Started

Create a Visio Graphics Service

To create a Visio Graphics Service by using Central Administration
  • Verify that you have the following administrative credentials:
    • To create a Visio Graphics Service, You must be a member of the Farm Administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click on the new ribbon and then click Visio Graphics Service.
  • In the Visio Graphics Service Application Name section, Type a name Ex- "Visio Graphics Service" in the textbox for the new service application.
  • In the Application Pool section, choose an existing Application Pool or Create a New Application pool name Ex- "Visio Graphics Service Apppool" in the textbox.
  • In the Application Pool section, choose a proper Account Ex- spservices from the Configurable dropdown.
  • Choose whether to create a Visio Graphics Service Application Proxy (recommended).
  • Click OK.

List all Visio Graphics Services

To list all the Visio Graphics Service by using Central Administration
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • The "Visio Graphics Service" is listed on the Manage Service Applications page

Delete a Visio Graphics Service

To delete a Visio Graphics Service by using Central Administration
  • Verify that you have the following administrative credentials:
    •To delete a service, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Select the Visio Graphics Service that you want to delete.
  • On the ribbon, click Delete.
  • In the confirmation dialog box, check the 'Delete data associated with the Service Applications' checkbox and click OK.

OR

To delete a Visio Graphics Service by using Windows PowerShell
  • Go to the Start menu, click All Programs.
  • Click Microsoft SharePoint 2010 Products.
  • Click SharePoint 2010 Management Shell.
  • From the Windows PowerShell command prompt (that is, PS C:\>), type the following below command and press ENTER:
    Remove-SPServiceApplication
Command: remove-spserviceapplicationpool "Visio Graphics Service Apppool"

Configure Visio Graphics Service global settings

To configure a Visio Graphics Service by using Central Administration
  • Verify that you have the following administrative credentials:
    • To delete a service, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click the Visio Graphics Service that you want to configure.
  • On the Visio Graphics Service Settings page, configure the following settings:
    • Maximum Diagram Size = 5 MB
    • Minimum Cache Age = 5 Minutes
    • Maximum Cache Age = 60 Minutes
    • Maximum Recalc Duration = 60 Minutes
    • External Data = the target application ID in the registered Secure Store Service that is used to reference Unattended Service Account credentials.
  • Click OK.

Configure Visio Graphics Service trusted data providers

The Visio Graphics Service trusted data providers can be provisioned through Central Administration.

Data Provider ID:

The Data Provider ID is the name of the driver that acts as the data provider. This ID must be the same ID that is used to reference the data provider in a connection string. The driver for the data provider must be installed on every application server that is running the Visio Graphics Service. Once you have installed the driver on your application servers, you can add it as a trusted data provider in Visio Services in Microsoft SharePoint Server 2010.

Data Provider Type:

When adding a new trusted data provider, the data provider type must be one of the following values:
Number Type
1 OLE DB
2 SQL
3 ODBC
4 ODBC with DSN
5 SharePoint Lists
6 Custom Data Provider
Data Provider Description:
The data provider description is a friendly name that appears in the Trusted Data Providers section of the Manage the Visio Graphics Service page in SharePoint Central Administration.

Creating, editing, and deleting trusted data providers

To create a Visio Graphics Service trusted data provider by using Central Administration
  • Verify that you have the following administrative credentials:
    •To create a trusted data provider, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click the Visio Graphics Service where you want to create the trusted data provider.
  • Click Trusted Data Providers.
  • Click Add a new Trusted Data Provider.
  • Enter values for the following parameters:
    Parameter Description
    Trusted Data Provider ID The Trusted Data Provider ID
    Trusted Data Provider Type The Data Provider type
    Trusted Data Provider Type Description Description of the Trusted Data Provider type
  • Click OK.

To edit a Visio Graphics Service trusted data provider by using Central Administration

  • Verify that you have the following administrative credentials:
    • To edit a trusted data provider, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click the Visio Graphics Service where you want to edit the trusted data provider.
  • Click Trusted Data Providers
  • Select the data provider that you want to edit, and from the drop-down menu select Edit Trusted Data Provider.
  • Edit the settings that you want, and then click OK.

To delete a Visio Graphics Service trusted data provider by using Central Administration

  • Verify that you have the following administrative credentials:
    • To delete a trusted data provider, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click the Visio Graphics Service where you want to delete the trusted data provider.
  • Click Trusted Data Providers.
  • Select the data provider that you want to delete, and from the drop-down menu select Delete Trusted Data Provider.

If you have any questions you can reach out our SharePoint Consulting team here.

Create and Configure Word Automation Service

Word Automation Services Overview

Word Automation Services is a new service application in SharePoint Server 2010. Word Automation Services provides unattended, server-side conversion of documents into formats that are supported by the Microsoft Word client application.
In simplest terms, Word Automation Services takes the "Save As…" functionality of the Word client application and replicates it for the server.

Specifically, Word Automation Services provides the following capabilities:

Opens documents that Word can open, including
  • Open XML File Format documents (.docx, .docm, .dotx, .dotm)
  • Word 97-2003 documents (.doc, .dot)
  • Rich Text Format files (.rtf)
  • Single File Web Pages (.mht, .mhtml)
  • Word 2003 XML Documents (.xml)
  • Word XML Document (.xml)

Supports all automatic tasks that execute when a document opens, such as:

  • Updating the Table of Contents, the Table of Authorities, and index fields
  • Recalculating all field types
  • XML mapping
  • Setting the compatibility mode of the document to the latest version or to previous versions of Word
Saves documents types that Word can save. This list is identical to the previous list of files that the Word Automation Services can open, but also includes the following types:
  • Portable Document Format (PDF) files
  • XML Paper Specification (XPS) files
With Word Automation Services, tasks that previously required you to run the Word client application can now be automated to run unattended in a more reliable and scalable way.

Start a Word Automation Service

To start a "Word Automation Service" by using Central Administration
  • Verify that you have the following administrative credentials:
    • To start a Word Automation Service, You must be a member of the Farm Administrators group.
  • sOn the Central Administration Home page, in the System Settings section, click on the Manage services on server.
  • If Word Automation Service is shown Stopped then click on the Start.
  • After clicking on the Start, Word Automation Service status is shown Started

Create a Word Automation Service

To create a Word Automation Service by using Central Administration
  • Verify that you have the following administrative credentials:
    • To create a Word Automation Service, You must be a member of the Farm Administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Click on the new ribbon and then click Word Automation Services.
  • In the Name section, Type a name Ex- "Word Automation Service" in the textbox for the new service application.
  • In the Application Pool section, choose an existing Application Pool or Create a New Application pool name Ex- "Word Automation Service Apppool" in the textbox.
  • In the Application Pool section, choose a proper Account Ex- spservices from the Configurable dropdown.
  • In the Partitioned Mode section, uncheck the 'Run in partitioned mode' checkbox.
  • In the Add to Default Proxy List section, check 'Add this service application's proxy to the farm's default proxy list' Checkbox.
  • Click Next.
  • In the Database section, Type the name of the database ex- WSS_Content_WordAutomation (that you want to use to store the document queue for this instance), and Type the default Database Server where that database is installed.
  • In the Database Authentication section, choose Windows authentication.
  • Click Finish.

List all Word Automation Services

To list all the Word Automation Services by using Central Administration
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • The "Word Automation Services" are listed on the Manage Service Applications page.

Delete a Word Automation Service

To delete a Word Automation Service by using Central Administration
  • Verify that you have the following administrative credentials:
    • To delete a service, you must be a member of the farm administrators group.
  • On the Central Administration Home page, in the Application Management section, click on the Manage service applications.
  • Select the Word Automation Service that you want to delete.
  • On the ribbon, click Delete.
  • In the confirmation dialog box, check the 'Delete data associated with the Service Applications' checkbox and click OK.

OR

To delete a Word Automation Service by using Windows PowerShell
  • .Go to the Start menu, click All Programs
  • Click Microsoft SharePoint 2010 Products
  • Click SharePoint 2010 Management Shell.
  • From the Windows PowerShell command prompt (that is, PS C:\>), type the following below command and press ENTER:
Remove-SPServiceApplication
Command: remove-spserviceapplicationpool "Word Automation Service Apppool"

If you have any questions you can reach out our SharePoint Consulting team here.

November 3, 2009

Display Full Error Description at Runtime in SharePoint 2007

Many times in SharePoint you will stuck at default error page. It says “An unexpected error has occurred” for all kind of errors.


This is very annoying part of SharePoint.

In such case, as a developer or professional, you have two possible ways to find out the exact error.

1) Go to Start > Control Panel > Administrative Tools > Event Viewer and check the internal error message, coz SharePoint itself logs all errors here.

Or

2) If you want to see the error on screen, you can edit configuration settings mentioned below.



• Navigate to web.config file of your SharePoint site.

In Windows Explorer, browse to the following folder

c:\inetpub\wwwroot\wss\virtualdirectories\site directory\site port number\

• Open web.config file in visual studio or notepad.

• Find word ‘CallStack’ and change status false to true

• Again find ‘CustomErrors ’ word and change mode On to Off

• Save and close the web.config file.

Refresh the error page, you will see original error message in screen instead of "An unexpected error has occurred" page.

If you have any questions you can reach out our SharePoint Consulting team here.

By: Piyush

October 28, 2009

Apply Custom Policy file to SharePoint Web Part

At the time of deployment of webpart, it is not possible for you to deploy DLL in GAC or have FULL trust level in the selected website.

In such case you can use custom policy file to come out from the problem.
Here are the steps to apply custom policy file to for your webpart(s).
·        Navigate to 12 hive\config folder.
·        Take a copy of WSS_Minimal.config file
·        Rename to [CompanyName]_minimal.config.
Open the new config file and add below code lines into the file as per given location. Add below code

 </NamedPermissionSets>

<CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing">

<IMembershipCondition class="AllMembershipCondition" version="1" />

<!-- New Code Lines added -->

<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust">

<IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="[Paste your Public Key BLOB]">

</IMembershipCondition>

</CodeGroup>

<!-- New Code Lines completed -->


Save the file. Don’t close it.

You need to add Public Key’s Blob file in addition to the above lines. To create the Blob you can follow the step below.

Open Start > All Programs > Microsoft Visual Studio 2005 > Visual Studio Tools > Visual Studio Command Prompt.

Type the following command
sn -p YourStongNameFile.snk PublicKeyOnly.snk

Where YourStongNameFile.snk is Your Projects SNK (Strong Name Key) file and PublicKeyOnly.snk is New creted PublicKey 

After you run the above command run the beloow command to create Blob:

 sn -tp PublicKeyOnly.snk

You will get your PublicKey's BLOB like below sample

 0024000004800000940000000602000000240000525341310004000001000100f9edc

57832372d0722d0ac9c068a482b47070d01b98ef1d7edd12eeec895e2a3d361220aef6

81d18c0cff1b2a9e606a18d968f6d4cceb148077c961d3e014a22b4049fb9c49c424f39e

6f192b27d961978ea766734432ce913b003b4085d7be21be2c570aa7c5a17506a25dac

84c2dd1ff037c22e147ab7ac563498b8602f8cf

 Copy this new blob and paste in config file in place the text “[Paste your Public Key BLOB]
that you kept open.

Save and close the config file.

  • Put your config file in 12 hive\Config folder.
  • Open you existing config file of your site and add one tag in config file under WSS_Medium,WSS_Minimal trust levels tags.

<securityPolicy>

<trustLevel name="WSS_Medium"  policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_mediumtrust.config" />

<trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\config\wss_minimaltrust.config" />

<!—Newly added code lines à

<trustLevel name="CompanyName_Minimal"  policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions \12\config\CompanyName_Minimal.config" />

<!—Newly added code lines end à

Now you have reached to the last step of the configuration,  change Trust Level WSS_Minimal to [CompanyName]_Minimal.

<trust level="CompanyName_Minimal" originUrl="" />

Save and close the config file.

Thats it J

If you have any questions you can reach out our SharePoint Consulting team here.

October 26, 2009

Enable Anonymous access in your SharePoint site

Many times you create websites in SharePoint. You assign different ports to access the site.

But what if you want to make the site internet facing and you want other to access the site with logging in to your site?

Yes this is possible.

Here are the steps to make a website as internet facing website.

1. Open Central Administration website of MOSS and navigate to

Central Administration > Application Management > Authentication Providers

The screen will look like below:




2. Select your web application that you want to enable anonymous access, from web application dropdown as displayed in below image.




3. Click on “Default” under Zone column. This will redirect to a new page. Check “Enable Anonymous Access” and click “Save” button.


4. Close Central Administration site.

5. Open the website that you selected for anonymous access. Login using administrator rights and navigate to Site Actions > Site Settings > People and Groups

6. Click “Site Permissions” from quick links. This will open up a new page as here:




7. Click on Settings under page header. Select “Anonymous Access”.




8. Close the browser and you are done.

If you have any questions you can reach out our SharePoint Consulting team here.

By: Alpesh