EzDevInfo.com

sharepoint-2010 interview questions

Top sharepoint-2010 frequently asked interview questions

Unable to delete SharePoint 2010 ContentType "Contenty type in use."

I have tried all the recommendations on the web, to no avail.

I wrote a console application per these instructions: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttypecollection.delete.aspx

The "Usages.Count" is = 0. Yet, when it tries to delete the Content Type I get an Exception:

"The content type is in use."

This is a brand new (development) install. I created a test site in SP Designer, created a Content Type,then a list. Then, I removed the list, removed it from Recycle Bin and tried to remove the content type...... Ugh.


Source: (StackOverflow)

Solving SharePoint Server 2010 - 503. The service is unavailable, After installation

Installed: SharePoint Server 2010 for Internet Enterprise Beta (x64) On: Windows Server 2008 Standard (x64) on 64 bit hardware

Attempts to access the Central Administration console led to IIS returning 503. The service is unavailable

And this error was found in the Application log

The Module DLL 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\owssvr.dll' could not be loaded due to a configuration problem. The current configuration only supports loading images built for a x86 processor architecture.

After much ado, the solution turned out to be:

1) Ensure that the enable32BitAppOnWin64 seeting for the "SharePoint Central Administration" app pool is set to False, and the same for the "SharePoint Web Services Root" app pool

2) Edit applicationHost.config:

Change:

  <globalModules>
 ...
 ...
 <add name="SharePoint14Module" image="C:\Program Files\Common
 Files\Microsoft Shared\Web Server
 Extensions\14\isapi\owssvr.dll"
 preCondition="appPoolName=SharePoint
 Central Administration v4" />
 </globalModules>

To:

    <add name="SharePoint14Module" image="C:\Program Files\Common Files\Microsoft
 Shared\Web Server Extensions\14\isapi\owssvr.dll" preCondition=
"appPoolName=SharePoint Central Administration v4,bitness64" />

I hope this helps somebody :-)

bitness64 being the magic word here


Source: (StackOverflow)

Advertisements

Add user to SharePoint 2010 group using powershell

We need to add several users to several SharePoint Groups.

Does anyone have an example of how to add a user to a sharepoint group using power shell.


Source: (StackOverflow)

How to Change SharePoint 2010 Project from Sandboxed Solution to Farm Solution

I created a new sharepoint project in Visual studio 2010 and by mistake it was sandboxed solution, after finishing my development its wont build because i am adding items to controltemplates and its saying i need to have the project as farm solution, so how to change th eproject type ?


Source: (StackOverflow)

How is SharePoint perceived in your company? [closed]

UPDATE An interesting time to revisit this question. Is perception still the same now that SharePoint 2010 is beginning to take hold? Certainly implementing 2010 is not without its own challenges, but is business perception one of them?

UPDATE: Our implementation is now kicking into high gear with some high profile projets going live in the coming weeks, so I am quite interested to see if the environment has changed out there.

Original Question

We have an issue within our working environment where the perception of SharePoint is either:

a) The golden bullet, the answer to all our problems.

b) An application which either does or does not solve a specific problem.

c) A frustrating tool which does not deliver their exacting requirements.

Now in my opinion SharePoint (or more specifically in our case Microsoft Office SharePoint Server 2007) is a framework on top of various lower level Microsoft technologies (IIS, ASP.Net, WSS 3.0, .Net Framework, Windows Workflow Foundation amongst others) and as such can be developed to do most anything (given time and resources).

The attitudes that have been formed in my organisation (and others I'm sure) is a combination of the Microsoft Marketing Machine and an organisaton's desire to get the 'golden bullet' in front of as many people as possible wihtout saying 'What for?' or 'Why?' or in some cases even 'How?'

Is this an attitude and perception shared by other SharePoint devs?


Source: (StackOverflow)

FileNotFoundException with the SPSite constructor. What's the problem?

I try to instantiate a instance of SPSite on the farm server in a custom software (MyApp.exe) and I give in parameter the whole website (http://mysite:80/). I also made sure that the account running MyApp.exe is Site Collection Administrator.

However, I can't make an instance of SPSite whatever I am trying to do. I always gives back "FileNotFoundException".

Anyone got an idea?

StackTrace:

at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl) at MyCompanyName.Service.HelperClass.GetItemStateInSharePoint(SharePointItem item) in C:\Workspaces\MyCompanyName\Development\Main\MyCompanyName.SharePoint\Service\HelperClass.cs:line 555

Another side note... I have a Web Application + Site collection that I can access through the browser without any problem.


Source: (StackOverflow)

Use credentials to interact with the Client Object Model of Sharepoint?

I need to write a small software which has to update some list on a Sharepoint 2010.

I found the "SPSite" which I can create with the url, but I can't figure out how to specify with which user I want to connect.

The user isn't the current windows user, and the program isn't executed on the server.

I saw the possiblity to give a "SPUserToken", but in my method I only have the user, the domain and his password, so how can I generate this user(and I think that this user is unknown on the system executing the code, but known on the server)

Where can I specify that?

Thank you!


Source: (StackOverflow)

SharePoint 2010 is forcing me to save PDF when opening from doc library

I have a document library with a PDF file. Whenever I click on the PDF file, I am prompted to save the file. I do not get the option of opening the file, I am forced to save it. What I want is for the PDF file to open, either in the browser or in a separate Adobe Reader window, depending on the Adobe Reader settings. I'm pretty sure SharePoint is responsible for this behavior, because if I put the PDF on my hard drive, then create a HTML file with a link to the file, it opens in the browser when I click on it.

Please note: I looked at this question and did not help. I don't care if the PDF opens in the browser or in a separate Adobe Reader window, I just want it to open.


Source: (StackOverflow)

Deploying custom dll's in SharePoint 2010

I'm new to SharePoint and trying to get my head around this. I have a simple Web Part project. I also have a custom Data layer project that uses the Microsoft Enterprise Library for data access. In the Web Part project, I am adding a reference to the Data layer project's assembly. I specified in the Package of the Web Part project that I want my Data layer's assembly to be deployed. I can verify this works by using standard ADO.NET classes and not the custom MS library. If I deploy to the SharePoint server (which I have 100% access to) using the Enterprise Library, I get the error message:

"Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data"

What steps do I need to take to ensure this project and all future projects on the server can easily gain access to the Enterprise Library for data access?

Thanks!


Source: (StackOverflow)

Change SharePoint Library URL

How do you change the URI of a SharePoint library? Based on Google searching, most people say that changing the name of a library in Designer (via right click->rename) will result in the URI change, but it is only changing the name for me.

I am using SharePoint 2010 Foundation and these are the steps I am following:

  1. In Designer, navigate to List and Libraries
  2. Right click library -> rename
  3. Notice that name changes
  4. Notice that URI does not change

This is one of the resources I found claiming that this works:

change URL spelling/case on sharepoint library


Source: (StackOverflow)

Sharepoint Out of the box Approval Workflow Approve/Reject comments issue when programmatically altering it

I have a re-usable out of the box sharepoint approval workflow 2010, and I am programmatically approve/reject workflow using the below code snippet inside infopath formcode (2010).

Hashtable ht = new Hashtable();
ht[SPBuiltInFieldId.Completed] = "TRUE";
ht["Completed"] = "TRUE";
ht[SPBuiltInFieldId.PercentComplete] = 1.0f;
ht["PercentComplete"] = 1.0f;
ht["Status"] = "Completed";
ht[SPBuiltInFieldId.TaskStatus] = SPResource.GetString
    (new CultureInfo((int)task.Web.Language, false),
    Strings.WorkflowStatusCompleted, new object[0]);
if (isApprove)
{
    ht[SPBuiltInFieldId.WorkflowOutcome] = "Approved";
    ht["TaskStatus"] = "Approved";
    ht[SPBuiltInFieldId.Comments] = "Approved by Manager";
    ht["Comments"] = "Approved by Manager";
}
else
{
    XPathNavigator navigatorRejectComments
        = this.MainDataSource.CreateNavigator().SelectSingleNode
           (XPATH_REJECT_COMMENTS, this.NamespaceManager);

    ht[SPBuiltInFieldId.WorkflowOutcome] = "Rejected";
    ht["TaskStatus"] = "Rejected";
    ht[SPBuiltInFieldId.Comments] = navigatorRejectComments.Value.Trim();
    ht["Comments"] = navigatorRejectComments.Value.Trim();
}
ht["FormData"] = SPWorkflowStatus.Completed;
web.AllowUnsafeUpdates = true;                                                            
isApproveReject = AlterTask(task, ht, true, 5, 100);                           
web.AllowUnsafeUpdates = false;

Task Alter method

private static bool AlterTask(SPListItem task, Hashtable htData, bool fSynchronous, int attempts, int  millisecondsTimeout)
{
if ((int)task[SPBuiltInFieldId.WorkflowVersion] != 1)
    {
        SPList parentList = task.ParentList.ParentWeb.Lists[new Guid(task[SPBuiltInFieldId.WorkflowListId].ToString())];
        SPListItem parentItem = parentList.Items.GetItemById((int)task[SPBuiltInFieldId.WorkflowItemId]);
        for (int i = 0; i < attempts; i++)
        {
            SPWorkflow workflow = parentItem.Workflows[new Guid(task[SPBuiltInFieldId.WorkflowInstanceID].ToString())];
            if (!workflow.IsLocked)
            {
                task[SPBuiltInFieldId.WorkflowVersion] = 1;
                task.SystemUpdate();
                break;
            }
            if (i != attempts - 1)
                Thread.Sleep(millisecondsTimeout);
        }
    }
    return SPWorkflowTask.AlterTask(task, htData, fSynchronous);
}

This code works fine, but the comments of the task is not getting altered and it is not included in the e-mail as well. Is there anything wrong with ht["Comments"] that I use? It is not getting altered in task comments. This is SharePoint 2010 workflows and infopath form i am using is also 2010.

Anyone faced similar problem ?


Source: (StackOverflow)

What does this Javascript code do?

I've been looking at Sharepoint script files and I've come across this bit that I don't get:

function ULSTYE() {
    var o = new Object;
    o.ULSTeamName = "Microsoft SharePoint Foundation";
    o.ULSFileName = "SP.UI.Dialog.debug.js";

    return o;
}

SP.UI.$create_DialogOptions = function() {
    ULSTYE:;   <----------------------------- WTF?
    return new SP.UI.DialogOptions();
}

Actually every function definition in this file starts with the same ULSTYE:; line right after the opening brace. Can anybody explain what does the first line in the second function do?

Firefox/Firebug for instance interprets this function as something that I can't understand either:

function () {
    ULSTYE: {
    }
    return new (SP.UI.DialogOptions);
}

And I thought I knew Javascript through and through... ;) Must be some obscure feature I never used in the past and is obviously seldomly used by others as well.


Source: (StackOverflow)

SharePoint error: Web application at xxxx could not be found

When I try to execute this code:

SPSite siteCollection = new SPSite(@"http://sp-devxxx:10000/");

It throws the following error:

The Web application at http://sp-devxxx:10000 could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

I can hit this site from my web browser, it is compiling in x64, my account has read/write access to the content db, the code is running on the server that the site is running on and there exists an access mapping for this site. Why would it be throwing this error?


Source: (StackOverflow)

Getting members of an AD domain group using Sharepoint API

In my Sharepoint code I display a list of all defined users via:

foreach (SPUser user in SPContext.Current.Web.AllUsers)
{
    ...
}

The great part is, I can add a domain security group to a Sharepoint group (like Visitors) thus adding many users at once (simpler administration). But my code doesn't see those users at least not until they log-in for the first time (if they have sufficient rights). In this case I can only see the domain security group SPUser object instance with its IsDomainGroup set to true.

Is it possible to get domain group members by means of Sharepoint without resorting to Active Directory querying (which is something I would rather avoid because you probably need sufficient rights to do such operations = more administration: Sharepoint rights + AD rights).


Source: (StackOverflow)

Can two or more people edit an Excel document at the same time?

I have a SharePoint 2010 site with a document library for storing Excel files. If someone is editing an Excel file (using stand-alone Excel, not Excel services), everyone else will be forced to open the file read-only until the first person is done editing. Is there a way around this? What I want is to allow two or more people to be able to edit the file at the same time. Also, I don't want people to overwrite each other. Instead, I'd like SharePoint to merge their changes. Is this possible in SharePoint 2010?


Source: (StackOverflow)