newtelligence poweredRSS 2.0
# Wednesday, February 03, 2010

Scenario

Locally developed Asp.Net MVC 2 application which needs to be deployed to a remote web server. The web server, running IIS 7.5 is hosted by a 3rd party, but we have full administrative access (Virtual Machine). In order to meet our deployment needs, we will install and configure MSDeploy. MSDeploy is a new add-on for IIS 6 and above which enables the package and installation of web applications, and optionally remote deployment and administration. You can also use it to synchronize settings between web servers, for example in a Web Farm. It is the remote deployment that we are most interested in, which is built upon the packaging and installation piece. For this post I will be assuming a deployment source of Visual Studio 2010 Beta 2. MSDeploy ships with an API which can be used to do the deployment from say a build task on a Build Server (stay tuned for a follow-up post on that).

Installation

First you need to download MSDeploy to your remote web server and install it. Here is the direct link for the 64 bit version of MSDeploy. Other version can be downloaded from the MSDeploy website. Once downloaded, run the MSI installer and select the custom option. You need to select the IIS 6 Deployment Hanlder to get the remote deployment feature. I also select the UI Module and Management Service Delegation UI (See screen shot below). After selecting the desire components, hit next, then install.

image

Configuration Overview

If you had IIS Manager open during the installation, you will need to restart it. Once restarted, you can right click on the Default Web Site and you should see a deploy option listed.

image

Next we will be configuring some accounts and permissions for our remote deployment, following the instructions provided by Microsoft, which can be viewed in their entirety here. Following these rules we will be able to create a specific account for our application which limits our external exposure. I’m happy to see we can use the new IIS Users/Management feature instead of having to create a local or domain windows account. Here is an overview of the steps we will be doing:

  1. Create an IIS Manager user account for the customer.

  2. Give the WMSvc account access to the customer’s directory.

  3. Configure delegation for the customer.

  4. Add delegation rules for the customer.

  5. Restart the Web Management Service.

  6. Test the Web Deployment Handler.

Step 1 – Create an IIS Manager User

In IIS manager, select the root server level (this is usually named after the name of the computer IIS is running on, it’s the node just below Start Page). Once selected scroll down in the middle pane to the Management section and select IIS Manager Users.

image

  • Double click on IIS Manger Users
  • Click Add User from the actions list on the far right side
  • Enter a username, and a strong password
  • Click OK

I used the naming convention, [AppName]User, and a randomly generated password from KeePass. Once created you get additional options for managing the user, like Change Password, and Disable.

Step 2 – Grant the WMSvc account access to our directory

The Service name (as shown in the Services MMC) is Web Management Service, and is not started by default. Using the Services MMC, start the Web Management Service and set it’s start-up type to Automatic, or Automatic-Delayed.

Note the user account that the service is running under. By default it runs as Local Service. You will need to Grant the Local Service account full permissions to the targeted deployment directory. Since I’d like to look into running the Web Management Service as a lower privileged account in the future, I took the extra steps to create a local user group called MSDeplyUsers, added Local Service to it, and granted permissions to the group. This will allow me to more easily switch accounts in the future.

Before proceeding, you may need to make an additional change to your IIS server configuration. By default, the Management Service is not configured to accept remote connections. While the Web Management Service is stopped, in IIS Manager, click your top level server node on the left, and then select Management Service under Management in the center pane.

image

Check the box for Enable remote connections, and select a SSL certificate. I’m using a self signed SSL cert for now. I also added IP restrictions to restrict remote deployments from my office only. You can use www.whatismyip.com to determine you IP, but unless you have a static IP, you may have to come back and change this often. You will also need to add the port specified to your allow section in your firewall rules.

image

Step 3 – Configure Delegation

In order for our user account we created in Step 1 to have access to their folder, we need to grant permissions on the folder (or site). You can only set folder level permissions if the folder is setup as an Application.

Once you have selected the level (using the navigation tree on the left) at which to grant permissions, you can select the IIS Manger Permissions option in the central pane.

image

  • Click on IIS Manger Permissions
  • Click on Allow User on the far right pane
  • Select IIS User and then select the user you created in Step 1

Step 4 – Add delegation rules

We now need to grant some specific rights to our user so they can deploy. This is done using the Management tools at the server level.

  • Double click on Management Service Delegation
  • Click on Add rule on the actions pane
  • Select the Deploy Content Only Template (I, as an administrator will handle the configuration of the application directory and advanced configuration).
  • Accept all default
    • Providers: contentPath
    • Actions: *
    • Path Type: Path Prefix
    • Path: {userScope}
    • Run As: Current User
  • When you click OK, you will be asked to provide the name of a user to add to the rule. This is where you specify your user you created in Step 1.

The steps for IIS 7.5 may differ from IIS 7.

Step 6 – Restart Web Management Service

Pretty self explanatory, using the Services restart, or start the Web Management Service.

Step 7 – Test

In visual study, you need to publish your web application to your newly configured remote server. Right click on your web project and choose Publish. In the screen that comes up, select MSDeploy Publish as your Publish Method and fill in the settings to match what we did in Steps 1 – 6.

image

Assuming everything is setup correctly, you should be able to publish you application to your remote server. Based on the rules we setup in Step 4, this will only publish content. It will not deploy database scripts, or create the application for you (mark the folder as an application). You can follow the more detailed instructions to set this up, but I wanted to keep this simple for now.

Trouble Shooting

Nothing ever works right on the first time does it? It took me a couple of tries (by couple I mean hundreds) to get all the configuration setup on the client and server. Here are some of the errors I got and what I did to fix them:

Connection Timeout

Could not complete the request to remote agent URL 'https://Server:8172/msdeploy.axd?site=<site>'.
Unable to connect to the remote server
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <Server>:8172

If you get connection timeouts, make sure you can browse to the Service URL entered above in the publish web screen. If you can’t, you hosting provider may be blocking port 8172. You should at least get prompted for credentials when using a Web Browser. If using a self signed cert, you will also get a certificate warning in the browser. Finally, you should see you attempt in the Log Files for the Management Service. The default path for the log files is: %SystemDrive%\Inetpub\logs\WMSvc

Error 400 Bad Request

Remote agent (URL https://Server:8172/MsDeploy.axd:8172/msdeploy.axd?site=<site>) could not be contacted.  Make sure the remote agent service is installed and started on the target computer.
An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected.
The remote server returned an error: (400) Bad Request.

This one was driving me nuts, and the fix/cause is absolutely ridiculous. Notice the two /MsDeploy.axd, one pascal cased, and the other all lower case. Now take a look at the following screen shot and compare have I have in the ServiceUrl and the example service URL provided in the same dialog.

image

Looks like it should work right? Nope, doesn’t work. What fixed it, changing it so that the /MsDeploy was all lower case as in https://Server:8172/msdeploy.axd. This got rid of the first MsDeploy.axd.

Error 401  

Remote agent (URL https://Server:8172/msdeploy.axd?site=Default Web Site) could not be contacted.  Make sure the remote agent service is installed and started on the target computer.
An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected.
The remote server returned an error: (401) Unauthorized.

The first question I had was, is the site “Default Web Site” correct? I was worried about the spaces in the name, but after reviewing the log files, the correct escape characters for a space where present. The full result code was a 401.2. I saw that my user account I created in Step 1 was being passed thru, and assumed that it had something to do with that.

I changed my credentials to an Windows Administrative account and gave that a go, and it worked. This means the service itself works, but either my authentication or authorization for the IIS user account is incorrect. If you are having problems with an administrative account, you need to make sure that you have the option enabled for Administrators to bypass rules. This is under Management Service Delegate, Edit Features. If you change this setting, you need to restart the Management Service.

image

When I had the Allow Administrators to bypass rules box unchecked, I got a different error message, one that said I was unauthorized to perform an action, not a 401. This led me to believe that my IIS User was suffering from an Authentication issue, not authorization.

Since the IIS Users are for management, I decided to try connecting to my Application using the IIS Management tool. Running this as a non-administrator you presented with a “empty” view. Right clicking on clicking on Start Page allows you to Connect to a Server, Web Site or Application. Selecting Application, and entering my credentials left me with a 401 Unauthorized error, confirming my belief that its a problem with the IIS User and not MSDeploy.

image

After playing around with the IIS settings, the IIS User account started working when connecting via IIS Manager, but not via VS. I do not believe I changed anything (without changing it back) to explain why it started working in IIS manager. The result codes when it was failing was the same 401.2 as I was getting when connecting via IIS.

For now I have to leave this as an open issue, and maybe try again on a local server.

UPDATE:

I got it working more or less. Check out the comments for what I had to do.

Wednesday, February 03, 2010 9:45:53 PM (GMT Standard Time, UTC+00:00)  #    Comments [3] -
Programming | Visual Studio
# Tuesday, February 02, 2010

IIS 7 introduced the concept of the Application Pool Identity, but it was not used by default. This was changed in IIS 7.5, and it is a change I fully endorse. The Application Pool Identity is a special account that is created per application pool which adds additional process isolation between your application pools.

The tricky thing is granting permissions to this special account. The account has a fully qualified name of “IIS AppPool\ApplicationPoolName”. However I was unable to get this account to be added via the GUI. I needed to resort to the command line tool icacls, which has a grant syntax of:

icacls path /grant “IIS AppPool\ApplicationPoolName”:RX

This will add the user with “special permissions” for reading. After you do this, the account shows up in the GUI and you can go in and just check the standard boxes for read rights (Read & Execute, List Folder contents, Read). Once you check these boxes the special read permissions that were initially set are removed, and everything looks like it usually does.

For network access, the AppPoolIdentity accesses the network using the machine’s domain account which is DomainName\MachineName$. The article says that this is how NetworkService worked, and that this makes it easy to add ACLs by just granting them to the Machine Account. Maybe I am unnecessarily paranoid, but I would prefer to grant access to network resource on a per app pool basis, which most likely requires a separate domain account. However, since I do not need network access right now, I will proceed with the AppPool Identity and write a follow-up post when I need to go down the domain account path.

You can read more about the AppPool Identity here: http://learn.iis.net/page.aspx/624/application-pool-identities/

Tuesday, February 02, 2010 8:46:42 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Technology

I have been meaning to write this for a couple of weeks now, my year in review and what's in store for 2010. Unfortunately I ended up in the hospital with a ruptured appendix and a minor complication that kept me there for 8 days.

Year in Review
2009 was a pretty good year for me. I started competing in the sport of Triathlon, finishing well in 2 half iron distance and 2 Olympic distance events.

My 2009 race schedule was to get some experience before attempting Ironman Wisconsin in 2010. I am pretty set on gear, with all my major purchases completed last year, and the last big one (Power meter) I just took care of. I picked up a used Argon 18 E-114, Kurt Kinetic Indoor trainer, Nineteen Frequency Wetsuit, Garmin Forerunner 305 GPS and just ordered a Powertap SL+ system. I gained a lot of valuable experience during my 09 races, and I am excited to see how much I can improve over last year. The biggest thing I learned was that my bike volume was not high enough to support the bike effort I was attempting on race day.

On the professional side of things, I finally got off the side lines and presented at the Madison .Net User group on Sharepoint 2010. For my first presentation, I think I did an ok job and the feedback I got was mainly positive. I still need to get my free copy of resharper so I can give it one more try. Also on the professional side, I accepted a new position as a Software Engineer with a new startup called Madison Research Technologies (MRT). MRT is working on developing a technical solution to a costly problem in the health care industry. I'll be able to talk about it more once we launch the product. I can tell you that I’m using a Microsoft Stack (what else would I be using) consisting of Asp.Net MVC and SQL Server.

To end my year right, and to get me psyched for Ironman training, my body thought it would fun to put me in the hospital for a week with a ruptured appendix and a pretty serious case of Ileus. I got the NG tube passed up the nose (while awake) and didn’t get any food for almost a week. By the time I got home, I had lost 7 pounds, and no it wasn’t water weight, seeing as I was on an IV continuously.

2010

The biggest thing I have going in 2010 is my first Ironman, Ironman Wisconsin, on September 12th. I just had my first full week of training the last week in January. Since that was an “off” week, it was a good week to start back up after my little appendix issue. My FTP is down 25-30 watts, running speed is down 1 mph, swim speed is down, heart rate is up, and endurance is shot. The good news is, I know what I need to do to get back into shape. I know what I’m capable of with the mediocre training schedule i had last year, so with all the hours I’m scheduled to put in this year, I should be back on track in no time. Be sure to keep an eye on my fitness category if you want to know how I’m doing.

My new job at MRT is going very well. It’s nice to be doing a little more programming, especially with Asp.Net MVC on the web side of things. It’s a bit of a change from Terso, what with averaging 1 e-mail/day over the last 3 weeks, and I think I was the first person to schedule a meeting in Outlook. If Terso was small with 20 people, MRT is really small with only 6. Speaking of Terso, if you check out the front page of the Terso Corporate Website, you can see my wife demoing the new Terso TS032 Intelligent Cabinet. I always wanted to be married to a Model ;)

I wanted to put more effort into this post, but since it’s February already, it’s outdated already before I even post it. I hope to make up for this with some additional posts in the near future.

Tuesday, February 02, 2010 3:37:43 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
General
# Friday, January 22, 2010

From time to time I have a need for a virtual com port, com port splitter, com port redirector (local and tcp),but most solutions I have found cost too much money. I’ve been able to get by using the named pipes redirection in Hyper-V for some of my projects. Yesterday I came across VSPE by Eterlogic, which offers every feature you could possible need, for FREE! There is a catch though, the 64-bit support costs $24.95, which they say is to cover the cost of the digital signing certificate required to sign their drivers for 64-bit Windows versions. I was able to try the software out on a 32 bit workstation, and it works as advertised. The next time I need something like this, and I’m developing on a 64-bit work station, I will not hesitate to purchase a license, even if it’s just for my home projects.

Friday, January 22, 2010 4:35:32 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
Tools
# Wednesday, January 20, 2010

I’m doing a little shopping for a virtual dedicated or cloud hosting provider. I need RDP access to install what ever I need, so Azure is out for the time being. The Amazon pricing page and model was giving me a headache, but after taking a break and coming back, I figured out the correct order to click thru the various information screens and have figured it out. Bandwidth, storage and performance needs are also quite small for the time being, but I wouldn’t consider running with anything less then 2GB of ram for Server 2008, and 2 virtual CPUs is nice.

Minimum Feature Set:

  • 2GB ram
  • RDP connection
  Amazon CrystalTech GoGrid MaximumASP OrcsWeb #1 OrcsWeb  #2
Plan Name 1 Small 24/7 Hyper-V VPS Small Biz MaxV Plan B B C
Total Monthly Price 97.86 $279.95 202.89 $178 $129.99 $179.99
Setup Price $0 $199.95 $0 $0 $0 $0
IP Addresses 1 2 10 2 1? 1?
VCPU 1 ?? 1 2 1 2
RAM 1.7 2 GB 3 2 GB 2 2
Disk Quota 160 GB 120 GB 60-120 GB 40 GB 60 120
Backups Included $80 + $25 setup Included Included Included Included
Bandwidth 10GB In
10GB Out
2000 GB Free Inbound, $0.29/GB Outbound 200 GB 250 GB 250 GB
Trail       30 Day Free Trial    
Notes     For billing, assume 10GB/mo outbound transfer. Disk quota is based on compute unit   Scott Hanselman uses them  

 

Cloud Computing

Cloud computing is all the rage, but its still in its infancy. As such, features are missing and things are still a little rough around the edges. For true elastic computing, Amazon is the way to go (remember, I was not looking at Azure for this comparison). The reason for this is that you can not stop your instances on GoGrid without deleting them. I’m not even sure if I would consider GoGrid a cloud provider without the ability to stop running instances, they are more like an on-demand virtual dedicated provider. GoGrid does offer some advantages over Amazon. They have free inbound data transfer and hybrid hosting. Hybrid hosting allows you to use their “cloud” offering for your web front end, while you can setup a managed dedicated server with some serious hardware for your backend database.

One downside to both services is that you can’t change the specs of an instance after it is created. Since both services let you create your own images (which you have to pay to store), once you get a base machine setup, you can create an image of it and then create new instances from your own image which would cut down on time to deploy. Hopefully the ability to reconfigure an instance is a feature on the roadmaps for both services. If you are going to be doing anything more then single server setups/testing, I would recommend storing your data on the Amazon ESB or GoGrid’s CloudStorage which offers non-instance persisted storage. GoGrid gives you 10GB free, while for the same space, Amazon would charge $1/month. Remember, the ESB or CloudStorage is where you keep your images as well, so it will fill up fast if you storing Windows Server 2008 Images (which clock in around 10GB).

While for the most part, ram is ram, the compute definitions differ between Amazon and GoGrid. Amazon offers standard and hi-compute units, while GoGrid just offers more virtual cpu’s with the larger instances (more ram). In my pricing comparison, I was using standard compute size instances from Amazon, which are the equivalent of 1.0-1.2 Ghz Opterons or Xeons. On the GoGrid side, they claim that 1 compute = a P4 2.0 Ghz, so there is a bit of a difference there.

If you have a lot of variation in your load, then Amazon will beat out GoGrid just because you don’t have to run around deleting instances, you can just shut them down. If you have a constant known load, then Amazon still beats out GoGrid, as you can take advantage of Amazon Reserved pricing. Reserved pricing requires you to pay a fee up front, but you get lower per hour rates for the duration of the term, 1 or 3 years. However, I like the GoGrid management UI better then the Amazon Control Panel.

Amazon:

  • 2 Small (1.7 GB, 1 compute) Front end web servers
  • 1 Small (1.7 GB, 1 compute) App Server
  • 1 Large (7.5 GB, 2 VCPU @ 2 compute) Database server
  • Load Balancer (Costs extra) + 25 GB of traffic (didn’t increase cost)
  • 25 GB inbound
  • 100 GB outbound
  • Price: $706

Amazon with Reserved

  • Same as above but using their reserved pricing option for a 1 year term. There is a upfront cost of $1538, but I divided by 12 and added to the other monthly fee for comparison
  • Price: 377.67

GoGrid

  • 2 2GB (1 compute) Front end web servers
  • 1 2GB (1 compute) App server
  • 1 4GB (3 compute) Database server
  • Load Balancer (Free)
  • Free Inbound
  • 100GB outbound
  • Price: $652

Conclusion

I’m going to give the Small Instance a try at Amazon, just to see how it works, but will probably end up going with one of the OrcsWeb virtual dedicated servers. For what I currently need, the OrcsWeb provides an economical, and probably more important, simple solution.

Wednesday, January 20, 2010 2:38:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [4] -
Technology
# Saturday, January 16, 2010

This post is part of my PDC09 Conference Notes series. These are my raw notes taken while watching the various session videos from PDC09. Refer to my original post for some conventions I tried to use.

PDC Session Link: Networking and Web Services in Silverlight

This session went over the different ways to expose data to a Silverlight application. Data access requirements for Silverlight was grouped in two ways and presented as the following graphic:

image

Each example fell somewhere on the X/Y axis of the chart above. Resource Centric was explained to be CRUD operations, while operation centric was more behavior driven.

Forms Over Data

The first examples were your typical forms over data applications, which are Resource Centric and follow a Request/Reply model.

If you control, and have direct access to the data, then RIA services was recommended. Aside from a short demo, not a lot of time was spent on RIA services, as there are other presentations that get into the details.

Another option for when you control the data, is to use WCF Data Services, which exposes your data in a RESTFul manner that adheres to the open data protocol (OData). In addition to data you control, services like SharePoint expose the data contained with-in via the open data protocol as well. The advantages to using OData sources over public REST services, is that more is known about the data, so you get a better development experience.

If you are working with a public data store exposed with REST, and it’s not OData, then use the enhanced (for Silverlight 4) ClientHttp library. It has a good programming model, and a lot of the deficiencies in previous versions have been solved. For example there is now support for Basic HTTP Authentication secured with SSL.

2 Way and Streaming

The second group of examples looked at duplex and streaming scenarios. The first example was a chat application which is an operation centric example that has some request/reply elements, but mainly users a duplex model. WCF was the recommend technology to support the duplex model. The included binary encoder provided a 71% performance improvement over the standard text encoder, even over HTTP. Binary has been the default encoder since Silverlight 3, but is only useful when both endpoints are .Net applications.

Duplex itself can be setup in your WCF bindings in one of two ways. For internet scenarios, you will need to use an HTTP binding, which is a polling based duplex model. While not present in the beta that was released at PDC, there are plans to enable HTTP Chunking, which would allow for multiple messages per HTTP request to increase performance. For intranet scenarios, you can use the NetTcp binding for the best performance. Remember, since this is WCF, you code once, and just change your bindings as needed.

Silverlight 4 supports UDP multicast, but it is pretty much an intranet only solution, as your network must be configured to support UDP multicast.

There is a new Silverlight TCP Socket Policy server project template in the online template gallery (accessible in VS 2010). This makes it very easy to setup the policy server to allow cross domain socket calls for your Silverlight application. An enhancement being considered for Silverlight 4 is that if the application has been elevated, then you will not need to worry about policies.

Saturday, January 16, 2010 10:49:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Conference Notes | Data Access | Silverlight
# Friday, December 18, 2009

I have been a big fan of log4net for the past several years. It’s a light weight, reliable, open source logging platform. Today I needed to create FileAppender that created a log file that had the current date in ISO 8601 format.

After playing around with various options for the RollingFileAppender, I finally figured out the correct way to accomplish my goal. By adding the type="log4net.Util.PatternString" to the file element in configuration file, you can change the name of the log file at runtime based on properties within log4net. It just so happens, that one of the properties is the current date and time.

Here is my appender that I ended up with:

<appender name="MyAppender" type="log4net.Appender.FileAppender">
            <file type="log4net.Util.PatternString" value="logs\%date{yyyyMMddTHHmmss}.txt" />
            <appendToFile value="true"/>
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date %-5level %logger - %message%newline"/>
            </layout>
</appender>

I had just never seen the type attribute in the file element in any of the samples I’ve worked with before, so it took me awhile to figure out the correct search terms to narrow things down. I also found a site that makes it a lot easier to search the user mailing list: http://old.nabble.com/Log4net---Users-f154.html

Friday, December 18, 2009 4:44:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Programming
# Friday, December 04, 2009

Yesterday I gave my first public group presentation to the Madison .Net Users Group on SharePoint 2010. Even though I was working on the demos up until the time I left my house for the meeting, I still managed to do ok. The speaker evaluation ratings were mostly 4 or 5’s, but I would have had to been pretty bad to get anything lower.

I did get one comment, and that was that I let my voice trail off, and I remember doing this. I tend to think out loud, so that’s probably what this was. However, for a presentation, talking to one’s self looks kind of goofy, and would be even worse if I was mic’d up. So I need to work on this and make sure that I am either speaking to the group, or not at all.

What Worked

  • Writing out everything I wanted to say, word for word on the notes, which I know that you are not supposed to do (read from notes). This ended up working because I was able to recall most of what I wrote down without looking at the notes. I think that I will continue to try to write out what I want to say as a one more way of practicing for the presentation.
  • Overall length of the presentation was good
  • Demo to Slide mix was ok for this topic even though it was slide heavy. There was a lot of information to convey, and I felt that the audience was mostly new to SharePoint that they would appreciate a solid foundation
  • Demo’s worked out pretty well. I may want to consider adding more code comments to help explain things, as well as help me remember talking points

What Didn’t Work (or what do I need to do next time)

  • Number one on my list is don’t procrastinate. I need to allow myself enough time to run thru the presentation at least once.
  • Create some index cards that contain key information that I want to make sure I cover. This would have been useful on a couple of the slides were there was a lot of information to cover.
  • Make sure if you need to read something, that it’s readable in low light situations
  • Don’t re-use step by step hands on lab notes with pictures. Demo notes should be on a single page, unless you need to copy code.

Client Object Model

There were a couple of questions on the Client Object model, and I wasn’t able to answer them as well as I wanted to. So I did a little research and came up with a key points.

The Client Object Model provides a subset of the server object model functionally, which is exposed via a WCF web service. This is intended as  a replacement for custom wrappers around the asmx web services that have been available in the past. The client object model is unified across JaveScript, .Net CLR, and the SilverLight CRL, so if you learn it for one platform, you can re-use that knowledge on the other supported platforms.

The object model was designed in a way to encourage efficient network utilization thru the use of batching. As a developer, you add a series of commands to the context, invoke the cotnext’s ExecuteQuery method, and receive a set of batch results back from the service in JSON. Most of the details are handled for you by the object model, so it’s not like you have to worry about parsing JSON.

Links

Here are all of the links I used for my demo. And as an added bonus, I have included links to all of the SharePoint 2010 videos from PDC 2009. I only wish I would have had the time to watch them all before giving my presentation.

My Power Point Presentation

SharePoint Foundation (Server) 2010

Extra Stuff needed to Install SharePoint 2010 Beta

SharePoint 2007 – WSS 3.0 (Some of these resources still apply to 2010)

SharePoint PDC Videos

Friday, December 04, 2009 4:16:30 AM (GMT Standard Time, UTC+00:00)  #    Comments [1] -
SharePoint
# Wednesday, December 02, 2009

Tomorrow night I am presenting at the Madison .Net Users group. Tonight, I am pulling my hair out, trying to get my demos to work. How far am I? Well I’m on my second demo, but the first one involves 0 programming, so I don’t think that counts.

What is was getting in my way, was a nasty System.Data.Services.Client.DataServiceRequestException, complaining of an invalid DateTime value…somewhere.

System.Data.Services.Client.DataServiceRequestException was unhandled
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse()
       at System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at Demo1.Program.AddEmployees() in C:\_Files\Projects\Demo1\Demo1Completed\Demo1Completed\Program.cs:line 48
       at Demo1.Program.Main(String[] args) in C:\_Files\Projects\Demo1\Demo1Completed\Demo1Completed\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       Message=<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="
http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-US">Error reading syndication item: 'Error in line 5 position 14. An error was encountered when parsing a DateTime value in the XML.'.</message>
</error>
       Source=Microsoft.Data.Services.Client
       StatusCode=400
       StackTrace:
            at System.Data.Services.Client.DataServiceContext.SaveResult.<HandleBatchResponse>d__20.MoveNext()
       InnerException:

After installing Fiddler so I could analyze the post and it’s subsequent response, I tried setting the Modified and Created properties on the Entity to DateTime.Now to give them an actual value. The Modified and Created properties are on all SharePoint list objects. I hadn’t bothered setting them, because they were of type DateTime? and I assumed that SharePoint would set them. As a matter of fact, I watched a PDC session on this very topic and blogged about it. In the demo, the only thing Pablo set was the name and the job title and posted it via CURL, and it worked.

I tried setting the values to null, but I got the same error (and why wouldn’t I). I ended up setting the values to DateTime.Min value. This allows the POST operation to succeed, and the Created and Modified values are correctly set by SharePoint.

Other notes of interest:

  • Even though I installed VS 2010 with .Net 4.0, I still had to install the Ado.Net Data services 1.5 CTP2 for SharePoint 2010 to expose data via ListData.svc
  • When building an application in VS 2010 with the .Net 4.0, System.Data.Services.Client is added for you when you add a Service Reference. You do not need to add a reference to Microsoft.Data.Services.Client in the CTP 2.
  • Be sure to check out the different SaveChangesOptions available when you call SaveChanges for your service. The batch option really speeds things up, but if one update fails, they all fail.
Wednesday, December 02, 2009 4:36:17 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Data Access | Programming | SharePoint
# Sunday, November 29, 2009

This post is part of my PDC09 Conference Notes series. These are my raw notes taken while watching the various session videos from PDC09. Refer to my original post for some conventions I tried to use.

PDC Session Link: Advanced WPF Application Performance Tuning and Analysis

This presentation was how you can analyze and tune your WPF applications in 4 key areas: Memory Usage, Cold Startup Time, Warm Startup Time, and Runtime. There were several tools used through out the presentation, and the demos were very well done. I would recommend watching this session to get a better feel for the concepts. The sample application used for the session is called Fishbowl, and is a WPF application that lets you work with Facebook in new ways.

Introduction

  • Measure early and measure often
  • Be sure to test on older hardware
  • Grab low hanging fruit
  • Understand perceived performance (i.e. keep the UI responsive during long running requests)
  • Trade Offs
    • CPU vs. Memory vs. Disk IO
    • Within your application, you may have to pick and choose which features are faster then others

Memory Usage

  • 150MB of memory was deemed as high for an application like Fishbowl
    • I found this to be very surprising given how many seemingly simple WPF apps I have seen using over 200mb of memory at startup. Is memory cheap these days? Yes, unless you count limited memory on Netbooks, older computers, and virtual machines.
  • Process Explorer to view overall memory usage
  • Sys-internals VMap to view detailed memory usage by process
    • Image: .exe, .dll, etc
    • Heap: Pure managed applications should have lower native heap then managed heap. You will always have some native heap, as some CLR stuff uses native memory, like the render thread. Images (pictures) are also stored in the native heap and are one source of high native heap usage.
    • Managed:
  • The cause of the high memory usage was the use of 114 images for the startup animation.
    • # of images * width in pixles * hieght in pixles * 4 (32 bit color) = memory usage
    • 114 * 272 * 294 * 4 = 34.7MB
    • The actual cause turned out to be that the start view was not being disposed after it was finished, so the images remained in memory.
  • SaciTech Memory Profiler on memProfiler.com
    • Costs money
    • WPF perf team uses this tool internally
    • Lets you do snapshots so you can compare memory usage over time
    • You can drill down by object type, as well as what is holding onto the reference for a particular object.
  • Element count (virtualization) is another pain point

Cold Start

  • Cold start is impacting most by Disk IO
  • Windows Performance Tool Kit or Windows SDK?
    • xperf command line tool (there is a PDC session on xpef and ETW)
    • Event Tracing for windows (ETW): Add ETW statements to your app and profile with xperf
    • Demo showed a batch file to start up xperf
    • Look for for highest number of reads
  • Remove unneeded dll references
    • System.Windows.Forms and System.Windows.Drawing shouldn’t be needed in pure WPF application
  • If you are using only one or two methods from a dll, you could merge it into your application
    • You can use Scitech Mem Profiler to see how many types for dll to see you can eliminate or merge
  • If you are using a managed API that is dealing with win32 api’s, you could add p/Inovke’s to your code to eliminate an extra dll.
  • Be sure to test in release mode with no debuggers attached
  • You can use NGen to speed up cold start, but it might slow down warm start

Warm Start

  • Warm Start is CPU bound, so you will see high CPU usage. There should also be lower disk IO then cold start.
  • If you see low CPU usage, there might be something blocking, like network access (using xperf again)
  • CPU Profiler
    • Comes with Team Suite
  • WPF Perf
    • Part of Windows Performance tool kit
    • Check item count, is virtualization enabled. Sometimes virtualization can’t be used, like when list element height is dynamic, which would screw up the scroll bar

Runtime

  • More WPF Perf usage
  • Trouble shoot jerky animations
    • Layout vs. Rendering
  • Pererator Tool:
    • Review hardware IRT’s. In the example, 20 hardware IRTs was too high.
  • Problem was traced to drop shadow animation. Solution was to create two elements, one with and one without drop shadow, then toggle visibility
  • Other stuff
    • Don’t block on the UI thread
    • Virtualization when needed
    • Freeze your freezables
      • No change notification call backs
    • Hardware vs. Software
      • use RenderCapabilities.Tier to determine when you should dial down visual effects.
Sunday, November 29, 2009 4:36:28 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Conference Notes | WPF
Archive
<February 2010>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright 2010
Adam Salvo
Sign In
Statistics
Total Posts: 251
This Year: 26
This Month: 0
This Week: 2
Comments: 34
Themes
Pick a theme:
All Content 2010, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)