Welcome to MSDN Blogs Sign in | Join | Help

Eric Kraus' SharePoint/.NET Blog

What the field says about MOSS.

News

  • Subscribe to this blog


    Eric Kraus on Live Messenger




      Disclaimer
      These postings are provided "AS IS" with no warranties and confer no rights. In addition, these postings are my own and do not represent the views of Microsoft.
    WCF hotfix for .NET 3.5 and SharePoint 2010

    There is a optional hotfix for WCF 3.5 SP1 which is a prerequisite for SharePoint 2010.  Depending on the operating system, the relevant hotfix can be found below.

    Windows Server 2008 (RTM) with Service Pack 2:  KB971831

    Windows Server 2008 R2/Windows 7:  KB976462

    Instructions:  Install this hotfix after the SharePoint 2010 pre-requisites, but before actually installing SharePoint 2010.

    Additional pre-requisites can be install from the DVD, or downloaded manually.

    Automated SharePoint 2010 Install with PowerShell

    In one of my previous posts, I walked through how to provision a SharePoint farm using PowerShell. You can also install SharePoint from a CD using PowerShell as well.  I use this in my lab at home so I don’t have to attend the installs when I am rebuilding my virtual machines.

    Here’s the breakdown:

    1.  Create an XML file that looks like this.  This will do a Full Farm Install (quietly).  For other config files, check out  e:\Files\SetupFarmSilent\config.xml  (e: is the drive with SharePoint on it)

    sharepointInstall_config.xml
    ----------------------------------------------
    <Configuration>
        <Package Id="sts">
            <Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>
        </Package>

        <Package Id="spswfe">
            <Setting Id="SETUPCALLED" Value="1"/>
            <Setting Id="OFFICESERVERPREMIUM" Value="1" />
        </Package>

        <Logging Type="verbose" Path="%temp%" Template="SharePoint Server Setup(*).log"/>
        <PIDKEY Value="USE_YOUR_KEY_HERE" />
        <Setting Id="SERVERROLE" Value="APPLICATION"/>
        <Setting Id="USINGUIINSTALLMODE" Value="1"/>
        <Setting Id="SETUP_REBOOT" Value="Never" />
        <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
            <INSTALLLOCATION Value="c:\Program Files\Microsoft SharePoint" />
            <Display Level="Basic" CompletionNotice="Yes" AcceptEULA="Yes" />
    </Configuration>


    2.  Next create a PowerShell script, that looks like this  (save it to the same folder as the XML file above):

    Install-SharePoint.ps1
    ----------------------------------------------------
    $config = "sharepointInstall_config.xml"
    $bits = "e:\"
    cls
    Write-Progress -Activity "Installing SharePoint Quietly" -Status "Copying config file locally"
    Copy-Item $config -Destination $bits
    Write-Progress -Activity "Installing SharePoint Quietly" -Status "Installing SharePoint"
    cmd.exe /C "$bits\setup.exe /config $config"

    3.  Now run your script from PowerShell, with the the working directory set to the location of your script files:

    PS C:>  cd sharepointScript
    PS C:\sharepointScript> .\Install-SharePoint.ps1

    4.  Wait a few minutes and the install will complete quietly.

    5.  Proceed to provisioning the farm with PowerShell, here

    Note:
      Don’t forget to set your execution policy in PowerShell to allow the script to run.  Easiest (but least secure):  Set-ExecutionPolicy Unrestricted

    SharePoint 2010 Beta 2 is finally here!

    Microsoft just released SharePoint 2010 Beta 2!  Beta 2 will consist of build 14.0.4536.1000.  

    For Beta 1 users only or partners running an earlier version e.g. 14.0.4514.1009 (Beta 2 Escrow), you can upgrade to Beta 2 by installing this update:  KB_COMING_SOON


    Download your copy of SharePoint 2010 Beta 2 from MSDN Subscriptions
    (Subscribers only at this point)

    Capture


    Notes:
    PLEASE REVIEW the hardware and software requirements for SharePoint 2010.  These include cumulative updates and hotfixes for SharePoint 2010 to install properly

    http://technet.microsoft.com/en-us/library/cc262485(office.14).aspx

    At last news, Beta 1 and Beta 2 will time-bomb (expire) on October 31, 2010.

    Setting up a development workstation running SharePoint 2010

    http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx

    Summary of other great resources on SharePoint 2010


    Official Microsoft SharePoint 2010 Website
    http://sharepoint2010.microsoft.com

    SharePoint 2010 on MSDN   
    http://msdn.microsoft.com/en-us/library/dd776256.aspx 


    SharePoint 2010 on TechNet
    http://technet.microsoft.com/en-us/sharepoint/ee263917.aspx


    SharePoint 2010 Technical Articles on TechNet
         
    http://technet.microsoft.com/en-us/library/ee428287(office.14).aspx 


    SharePoint Developer Center
    http://msdn.microsoft.com/en-us/sharepoint/default.aspx


    SharePoint 2010 Development Hands On Labs
    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c010fc68-b47f-4db6-b8a8-ad4ba33a35c5#filelist

    SP2010: SPFarm.Local is null or Web Application could not be found

    Note: This post applies to SharePoint Server 2010 Beta 2 and Visual Studio Ultimate Beta 2.

    I ran into two issues today that had me tied up for a few hours so I thought I would share.  The first was simple:

    SPFarm _farm = SPFarm.Local;   However, the _farm object was being returned as null. 

    1_farmNull

    The second was again simple:

    SPSite _site = new SPSite(“http://teams”);   This line errored with:  


    2_WebAppCantBeFound

    The Web Application at http://teams 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.

    First, notice that by default, Visual Studio compiles in x86.  Since SharePoint is running in x64, this would definitely be a good place to start.

    3_CompilingIn86

    However, there is no x64 platform to compile to by default

    4_No64

    What we need to do is create an x64 platform and copy existing settings from x86.  We’ll do this by entering the Configuration Manager.  Once in the Configuration Manager, select the platform drop down and choose New.

    5_CreateNew

    Choose the new platform to be “x64” and choose to copy settings from x86.

    6_New64

    After you click OK, ensure the settings on your projects are change to use the new platform “x64”

    Close out of Configuration Manager and ensure you are now building in x64.

    8_BuildingIn64

    Lastly, try your project again.  That should have solved it.

    9_Worked



    Note:  you may also receive this error if you do not have permissions to the configuration database while developing a Windows Forms or WPF application.  Ensure that the account you are developing on has appropriate permissions to the config database.  If you are running a web client (web part, etc.), ensure that its app pool account has the same permissions to the read from the database.

    Special thanks to Tajeshwar for his help in resolve this.

    SharePoint 2010 Development Hands On Labs

    These HOLs are about a month old now, but I wanted to share them for anyone who missed the announcement at SPC.  There are 10 Hands On Labs in both C# and Visual Basic for SharePoint 2010 Beta 2.

    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c010fc68-b47f-4db6-b8a8-ad4ba33a35c5

    Also, I have set up several tags in Diigo for SharePoint , you can find my “SharePoint2010” bookmarks here:

    http://www.diigo.com/user/erickraus/sharepoint2010

    I update links to this site daily.

    SharePoint 2010 Provisioning A New Farm with PowerShell

    <Update 2009.11.20  Added Initialize-SPResourceSecurity
    and Install-SPApplicationContent  Thanks, Zach>

    This post will take you down the process of configuring your SharePoint farm while introducing the new administrative functionality shipping in the PowerShell provider.

    During the SharePoint Installation, make sure you choose “Server Farm” and then “Complete” install.  This will allow you to create a SharePoint farm rather than a standalone server.

    After the install completes, the setup program will ask you if you want to run the SharePoint Technologies Configuration Wizard (default is checked).  Uncheck the box to NOT run the wizard.

    Under the Start Menu, browse to Microsoft SharePoint 2010 Products.  Right-click on SharePoint 2010 Management Shell and choose Run as administrator

    0_StartPowerShell

    Notice:
    Since we have not created a farm yet, the shell will load with an error that the local farm is not accessible.  This is expected.

    Next, run the following command to create a new configuration database and central admin content database.  The main reason we are using this method, versus the GUI is because we can specify the central admin content database name.  (In the GUI, you cannot specify the name and it is created with a GUID)  <—DBA’s hate this

    New-SPConfigurationDatabase –DatabaseName “SharePoint2010_Config” –DatabaseServer “<db server>” –AdministrationContentDatabaseName “SharePoint2010_Admin_Content” –Passphrase (ConvertTo-SecureString “pass@word1” –AsPlaintext –Force) –FarmCredentials (Get-Credential)


    Notice: rather than hard coding the credential for the farm account, I am having PowerShell prompt me for it.  You can also do this with the passphrase by accessing the “Password” property of the of the credential object:  (Get-Credential).Password 

     


    1_NewConfigDB

    After the process runs, you can test that the server has not been added to a farm, by reloading the PowerShell window.  Close and repeat the “Run as administrator” step above.  It should load with no warning message.

    5_ReloadShowsFarmConnected

    Next, we need to provision the central admin web application on our desired port.  This will also link up the web application with the admin content database we created in the previous step.

    New-SPCentralAdministration -Port 1234 -WindowsAuthProvider "NTLM"

    Next, we want to install all of the help files within Central Admin

    Install-SPApplicationContent

    After that command completes, we need to secure the files and registry entries on the server otherwise we we will receive a whole bunch of weird security errors. 

    Initialize-SPResourceSecurity

    Next, we need to install the features on the server. 

    Install-SPFeature –AllExistingFeatures

    21_InstallFeatures

    Lastly, we need to install and and then provision the services onto the farm.

    Install-SPService

    Install-SPService  -Provision  (for standalone servers only)

    One of the last steps that I perform here is to Disable the Loopback Check on stand alone demo servers.  This setting usually kicks out a 401 error when you try to navigate to sites that resolve to a loopback address e.g.  127.0.0.1

    To disable the loopback check, run this command from PowerShell:
    New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword


    DONE!  Now, you can open up Internet Explorer to the central admin site/port you specified and you’re on your way!

    Or, since you’re now a PowerShell pro, run this command : 
    “start iexplore http://server:1234”
    PowerShell 2.0 Released!

    Windows Management Framework, which includes Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0, has been officially released today.  This down-level release is now supported for Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2 operating systems.

    You can find the release here:  http://go.microsoft.com/fwlink/?LinkID=151321

    Free PowerShell eBook

    For those wishing to get started on PowerShell, here is an excellent free eBook by Dr. Tobias Weltner, PowerShell MVP.

    http://powershell.com/Mastering-PowerShell.pdf

    Extending .NET Objects in PowerShell

    One of the great features in PowerShell 2.0 is the ability to extend .NET object types to add additional custom properties and methods.  For instance, the type System.String does not have a property called IsANumber that returns whether or not the string is a number.  Typically, you would have to do a TryParse.  By extending the System.String object, we can add such property.

    Here’s how it works:

    We will create a custom XML file that will define the .NET object that we would like to extend and how we want to extend it.  Then, we will load that XML into our PowerShell session and the new methods/properties will be available to us. 

    Types.ps1xml file, located at $pshome ships with PowerShell 2.0  It is a good place to look at example extensions.  Because this file is digitally signed, we cannot modify it directly, this is why we will create a custom XML file.

    Let’s get started.

    Open PowerShell by right clicking and choosing “Run as Administrator

    RunAsAdmin

    This next step (which is actually three commands) will create a new XML file “MyCustomTypes.ps1xml” at the $pshome location,  (typically:  C:\Windows\System32\WindowsPowerShell\v1.0) and open it in Notepad.

    $mycustfile = “$pshome\MyCustomTypes.ps1xml”; New-Item –ItemType File –Path $mycustfile; notepad $mycustfile

    Note:
    we are using PowerShell 2.0 but the install location for that is called “1.0”

    Next, add the following XML to the notepad window that opened:

    <?xml version="1.0" encoding="utf-8" ?>
    <Types>
      <Type>
        <Name>System.String</Name>
          <Members>
            <ScriptProperty>
              <Name>IsANumber</Name>
              <GetScriptBlock>
                    $out = $null; [System.Double]::TryParse($this, [ref] $out)
              </GetScriptBlock>
          </ScriptProperty>
        </Members>
      </Type>
    </Types>

    The $this property is the current object of the type you are extending.  In our example it will always be a string, since we are extending the System.String object.

    Save and close Notepad

    Back in PowerShell type the following command to load the custom types xml file and give it higher precedence than any other loaded file:


    Update-TypeData -PrependPath $mycustfile


    Now, to test that the new property has been added, we can create a new string variable and check the IsANumber property.

    RunTest 

    Below are a few of the different types of extensibility that you can perform:

    <AliasProperty> – defines a new name for an existing property
    <CodeMethod> – references a static method of a .NET class as a method for the object
    <CodeProperty> – references a static method of a .NET class as a property for the object
    <NoteProperty> – defines a property with a static value
    <ScriptMethod> – defines a method whose output is the value of a script
    <ScriptProperty> – defines a property whose output is the value of a script

    For more information:  
    get-help about_types.ps1xml  and  get-help update-typedata

    SharePoint 2010: A Developer’s Top 15 List

    Developers of SharePoint should be giddy with excitement in all of the tools and features coming out of Visual Studio 2010 and SharePoint Designer 2010.  Here are the biggest take-a-ways from Paul Andrew’s talk on the 2010 developer platform:

    1. “Save site as template” now exports as a WSP which can be imported into Visual Studio 2010 as a new project

    2. BDC is now Business Connectivity Services which supports full Create, Read, Update, Delete calls to sources, plus Office 2010 integration using new SharePoint Designer 2010 tools 

    3.  LINQ to SharePoint to replace complex CAML queries in code.  Strongly typed, intelli-sense, joins and projections
               
    4.  Developer Dashboard displays call stack, load time, and other valuable data to debug and review code

    5.  Relationships between lists, supporting cascade deletes (transactions are actually handled on SQL Server)

    6.  Large List?  No problem! Just be certain of data in views.  Use throttling and indexes for performance.  10’s to 100’s of thousands of documents = no problem.

    7.  Column Validation – lets us add validation logic when defining columns

    8.  Client Object Model – simple API to Add, Retrieve, Update and Manage data.  Commands are batched for performance:

    ClientContext cnt = new ClientContext (“http://siteurl”);
    Web site = context.Web;
    context.Load(site);
    context.ExecuteQuery();
    site.Title = “Something New”;
    site.Update();
    context.ExecuteQuery();

    9.  Rest APIs – uses ADO.NET Data Services.  Out of the box services in SharePoint.  Retrieve data off of site in 3 lines of code.

    10.  Better Events and Workflow.  Event Receivers and Workflows now possible at the site scope level (workflow does not bind to a list).  Event receivers can run asynchronously

    11.  Easily build dialog forms using AJAX. 

    12.  Silverlight web part out of the box. - code doesn’t need to run on server!!!

    13.  Sandboxed Solutions – can monitor counters on server (CPU, RAM, etc.) to automatically shutdown bad code.  Uses a proxy worker process so not direct access to Microsoft.SharePoint.dll

    14.  WSP is the unified developer platform (for both Site Collections and local machine)

    15.  Integration with Team Foundation Server (TFS):  work item tracking, source control, team build, manage test cases, automated testing, and load testing!

    PowerShell Cmdlets in SharePoint 2010

    You may have already heard that SharePoint 2010 will ship with a PowerShell provider that contains over 500 cmdlets for you to administer SharePoint. The killer though, is that these commandlets can be executed remotely with PowerShell 2.0 WinRM.  Awesome!  Don’t worry about STSADM, it will still be around to support existing administration scripts and utilities. 

    You can load the PowerShell provider by typing:

    add-pssnapin Microsoft.SharePoint.PowerShell

    Much of what Christian (iLoveSharePoint) and I have worked on in SPoshMod for SharePoint 2007 supports the same pattern as the 2010 provider.  Verb-Noun, with SP prefix.   Get-SPSite, Get-SPWeb, etc.

    What you may not know is that developers can add custom providers and deploy them to SharePoint.  You can do this by using the Microsoft.SharePoint.PowerShell  namespace.  To distinguish a normal PowerShell cmdlet from a SharePoint cmdlet, an new abstract class has been added to the namespace called: SPCmdlet  (other cmdlets inherit directly from PSCmdlet).

    More to come on this topic…

    Live Blogging from SharePoint Conference 2009

     

    I’ll be at SharePoint Conference 2009 and will be participating with EndUserSharePoint.com in their LiveBlogging sessions. 

    Live blogging/twittering at SharePoint Conference 2009:


    SharePoint Conference 2009

    I will be attending the SharePoint Conference in Las Vegas next week and wanted to share my schedule with those that might be interested in checking back for content.  I will be blogging on content throughout the event. There may be multiple sessions listed under a given timeslot as I will be narrowing down content as I attend other sessions. 

    I will be cross posting some content on my blog with EndUserSharePoint.com  more info can be found on my next blog post:

    --> Live Blogging from SharePoint Conference 2009 

    or on Twitter:   http://twitter.com/erickraus

    Monday, October 19th, 2009
    9:00 AM  - Keynote: Unveiling Microsoft SharePoint 2010
    Speaker: Steve Ballmer
    10:30 AM  -  Keynote: Microsoft SharePoint 2010 Drilldown
    Speaker: Jeff Teper
    1:15 PM  -  Overview of the SharePoint 2010 Developer Platform
    2:45 PM  - 
    SharePoint 2010 Administration: Part 1
    Visual Studio 2010 SharePoint Development Tools Overview
    4:30 PM  - 
    SharePoint 2010 Administration: Part 2
    Overview of Social Computing in SharePoint 2010
    Developing with SharePoint 2010 Sandboxed Solutions

    Tuesday, October 20th, 2009
    9:00 AM  - 
    Building Rich Internet Applications with Silverlight 3 and...
    Advanced Web Part Development in Visual Studio 2010
    Overview of Office 2010 for the IT Pro
    10:30 AM  - 
    Building A Great Extranet: Proven Principles & Best Practices
    Scaling SharePoint 2010 topologies for your organization
    1:15 PM  - 
    SharePoint isn’t just for Servers anymore
    Developing SharePoint 2010 Applications with the Client Object Model
    Authentication and Authorization in SharePoint 2010
    2:45 PM  -  Deep Dive into SharePoint 2010 My Sites and Social Networking...

    Wednesday, October 21th, 2009
    9:00 AM  -  Developing an Automated Site Management Lifecycle with SharePoint 2010
    10:30 AM  -  Business Connectivity Services Runtime and Object Model Deep Dive
    1:15 PM  -  Developing with REST and LINQ in SharePoint 2010
    2:45 PM  - 
    Externalizing BLOB Storage in SharePoint 2010
    Developing Social Applications with SharePoint 2010
    4:30 PM  -  Advanced Development for Silverlight 3 in SharePoint 2010

    Thursday, October 22th, 2009
    9:00 AM  -  Unveiling New Management Tools for Administering SharePoint 2010
    10:30 AM  -  Application Lifecycle Management for Developers in SharePoint 2010
    12:00 PM  -  Upgrading SharePoint 2007 code to SharePoint 2010

    Custom Site Definition Alternative

    This came up for a recent customer, so thought I would share my solution as many people are not aware of this customization possibility.  The solution ultimately solved the problem that feature staplers activate features BEFORE any lists are provisioned on a site.  So, the only eloquent way to modify a list or list item is to create a new list template in a new site definition.  Here is an alternative solution to consider instead of supporting another site definition in your environment.

    When SharePoint shows you the list of site definitions available to create a new site, it compiles this list from the list of files in: 12 Hive\TEMPLATE\1033\XML\    SharePoint will collectively pull all of the contents in the files named: webtemp*.xml and display a list of available site definitions.  By creating your own webtempcustom.xml you can effectively add site definitions to the list of choices at the ‘create’ screen. (nothing new here)

    However, you don’t necessarily have to create a site definition along with your webtemp*.xml file.  Instead, you can call custom code to build your site to your needs and return that site to the provisioning process.  This can be accomplished by leveraging the SPWebProvisioningProvider class when a new site is created.  This class, which is inherited from, is specified in your webtempcustom.xml file.

    Here is an example of a webtempcustom.xml file with the provisioning class specified:

    webtempcustom
    And the provisioning class:

    provisioningprovider

    Now, just deploy your xml file to the 12\TEMPLATE\1033\XML folder and your compiled DLL to the GAC.  When the site is created, it will still be created with the STS#0 (or the template you apply in your code.  Essentially, eliminating the dependency on any other site definitions.

    Another thought, you could even add the ProvisionAssembly and ProvisionClass to an existing template entry such as STS to override the provisioning process for an existing site definition.

    Twin Cities SharePoint Camp v3

    Here’s a great (FREE) opportunity to attend a day-long workshop completely dedicated to SharePoint.  Come learn from developers, IT Pros, consultants, and local companies who have implemented SharePoint and have a story to share.

    I will be presenting again this year on one of my favorite topics, PowerShell.  Here is an abstract of the session:

    PowerShell Administration and Development in SharePoint

    PowerShell is a hot topic for SharePoint 2007 and will be even more for 2010.  Discover the power of PowerShell 2.0 and PowerGUI as they are used to perform advanced administrative & development tasks in SharePoint.  This session will start with a brief introduction to PowerShell scripting and continue with a look into helpful SharePoint scripts including: filtering event and ULS logs, managing sites and users, streamlining feature development, managing web parts, working with the object model, and much more!  Both administrators and developers will benefit from this powerful discussion.


    More information, and steps to register, can be found here:  http://twincitiessharepointcamp.com/

    Hope to see you there!

    More Posts Next page »
    Page view tracker