.NET Development
When you’re accessing built in SharePoint fields (such as Title) from code, do you go: listItem["Title"] = xVar;
listItem[0] = xVar;
Don’t! Have a look at SPBuiltInFieldId that keeps tracks of the Id’s for the built in fields for you:
string title = myListItem[SPBuiltInFieldIds.Title];
I’ve been working for a while on a project and filled up the Site Collection Images list with a lot of images get the user experience going in my virtual dev environment. When we got access to the customer environment I wasn't in the mode to manually upload all the images again. So I wrote the following little console application that dumps out the content from the Site Collections Images list. The output from the app is:
Feature.xml - file containing the feature def and all elements
images.xml – file containing the Module...
This is one that my colleague Mattias showed me. When I code SharePoint solutions I’m always to put in some diagnostics logging just so that I can turn it on and se what happens. There is (as always) a couple of options here. Write to the ULS logs, which I guess is the preferred way to do it and then use event throttling to turn it on and off. However sometimes its just a bit to much work. So, here’s the trick.
Sprinkle Trace.Writer's in your code where it makes sense. So for example i might want do put the following...
Being home from work with a stomach bug today I was thinking on how I can be more effective in what I do. One thing that popped to mind is how often in a work day I lose track of what I’m doing just because I remember something else I have to do. When the idea pops up I go off to outlook navigate to the right place, add a task… And boom, my mind is way off track. So my thought was “how do I shorten the interruption so that it does not derail my train of thought”?...
Ever did a nice little console applications that does something smart and you’re satisfied with what it does but it’s kinda irritating that it steals focus and flickers by the screen during execution. Could be something like the GUID generator I wrote a while back, described in my post: Creating GUID’s. So here the simple solution: In Visual Studio 2008, right-click the project Choose Properties… Change Output type from Console Application to Windows Application. Done.
This have been my little weekend project this weekend (ok, some Christmas preparations to).
Background
As some of you know I play underwater rugby. The communication from the Swedish Underwater Rugby Association to it’s members is mainly through the news page on their site’s news page: http://www.ssdf.se/t3.aspx?p=51459 (in Swedish). This page is only exposing HTML and does not expose an rss-feed (they should have used SharePoint). My problem is that I never remember to visit the site with regular intervals, so I miss out on stuff.
Approach
As I truly am a RSS junkie, that’s what I wanted. To be able to...
Just encountered a problem that’s soooo simple to solve, but yet sooo frustrating when you encounter it. I was moving some code from my local prototype project up to the official dev environment. At first I forgot some entries in the app.config file. Piece of cake, right? So off to some cut-n-paste action and I ended up with this: Looks alright? Well it did to me, so imagine my surprise when I got hit with the following exception: System.Configuration.ConfigurationErrorsException was unhandled Message="Configuration...
A while ago I had an epiphany around using a stack data structure instead of recursion. Yeah, I know old news for most of you. But I don’t care, I just got it and it feels good. Anyway’s, for those of you that haven’t had that revelation yet maybe this example can help you there.
Problem
I have a scenario where I have to loop through a directory structure and look for csproj-files. What I do with them is not relevant to this example.
Solution 1 - Recursion
So, being a creature of habit I went for the recursive approach.
class Program
{
...
Are you one of those people saying that you can’t have code behind pages in SharePoint v3? Heck, I used to think that it was the case. I had this epiphany a while back. But never put it into writing, good thing some people are better at this. Check out Andrew Connell’s article on the subject, he always does a good write up. Using ASP.NET 2.0 Code Behind Files in SharePoint v3 Sites
I was at a client this week who are using Team Foundation Server as their code repository. So, I got an account fired up Visual Studio and though that since I installed Team Suite edition extra everything and don't hold the gravy... that Team Explorer would just be there... Wrong! So I had to get a hold of the Team Foundation CD and in the \tfc (think that stands for Team Foundation Client) and run the setup. Maybe this post can save someone else a little time.
This blog is running SubText as blog engine. It works great, the biggest thing I'm missing is stats. I don't have many readers but it's fun to know just how few they are. So first step in this was to let FeedBurner handle the distribution of my RSS feed and get some simple stats on that. The next step was to get some stats on the actual blog. I signed up for Google Analytics when they first released it for testing, but haven't used it much since. Now I thought why not put it to the test. To get it collecting data...
Is really simple! Here is a small sample where I extend the content type "Document" by adding the field "Office". Not really useful but shows how it's done. SPSite site = new SPSite("http://moss.litwareinc.com");
SPWeb web = site.OpenWeb("/SiteDirectory/t2");
//Create Content Type (extending Document content type)
SPContentType documentContentType = web.AvailableContentTypes["Document"];
SPContentType newContentType = new SPContentType(documentContentType, web.ContentTypes, "Niklas Document");
web.ContentTypes.Add(newContentType);
Console.WriteLine(newContentType.Id.ToString());
//Add FieldLink
SPField fieldOffice = web.AvailableFields["Office"];
SPFieldLink fieldLink = new SPFieldLink(fieldOffice);
newContentType.FieldLinks.Add(fieldLink);
newContentType.Update(false);
This is a really good post on how to leverage the solution and feature framework in SharePoint 2007.
The MOSS team realized a little too late that they sealed the AspMenu-class for extension in WSS v3 / MOSS 2007. So doing the next best thing and released the source code for it. Read this post and download the source.
I've started thinking about accessibility in MOSS 2007 (especially WCM scenarios) and this could be a way to get the menu-control to emit a little less html-tables. Tough what I really would like to do is to get CssAdapters to work with AspMenu, but that is still at the idea-stage in my mind...
In this post I'm going to try to explain what a Feature Receiver is in SharePoint 2007 and show you an example of how to use it. First things first. What is a SharePoint Feature A feature is kinda tricky to explain. It's a functional unit that can be activated and deactivated in different scopes (site collection, web etc). There is a bunch of features out of the box as seen below. Problem definition In a recent project we decided to deploy a big chunk of meta data columns (site columns) as a feature. A couple of these columns...
I've used Telerik's r.a.d Editor Lite for Microsoft Content Management Server 2002 before and I can say that it was not a dissapointment! I had to tweak it a little to get fully compliant xhtml, but that was due to a by design issue in MCMS 2002.
Now Telerik delivered thier r.a.d editor for SharePoint 2007. Which has a lot of nice features, such as:
Cross browser support
Accessibility - Section 508 compliant
Support for listings, list items and more
And what's more, it's free for all Microsoft Office SharePoint...
Lawrence Lui have set up a nice SharePoint Community Serach at Live.com. Nice going!
You can easely set up you own search engine at live.com if you like.
Finally we released Windows SharePoint Services extension for Visual Studio 2006. Templates available in this release is:
Team Site Definition
Blank Site Definition
ListDefinition
Web Part
Grab the bits here.
Ever felt like you wanted to extend SharePoint's administration utility stsadm.exe with some of your own commands? Well now in MOSS 2007 it's possible. Some xml configuration and implementation of the ISPStsadmCommand interface. Tony Bierman has an excellent post here on how to do this and Andrew Connell has written a few custom extensions.
Just sometihing I had to do yesterday, getting and setting properties using System.Reflection in .Net, tought I share. Get propertyAssembly assembly = Assembly.LoadFrom(assemblyPath);
/* ... */
object o = Activator.CreateInstance(t);
PropertyInfo propertyInfo = t.GetProperty("CustomProp");
object val = propertyInfo.GetValue(o, null);
Set PropertyAssembly assembly = Assembly.LoadFrom(assemblyPath);
/* ... */
object o = Activator.CreateInstance(t);
PropertyInfo propertyInfo = t.GetProperty("propertyName");
propertyInfo.SetValue(o, "propertyValue", null);
I'm reading up a little on SQL Server 2005 and found a couple of deprecated features worth noting.
TIMESTAMP - use rowversion instead for theese operations
SET ROWCOUNT - wich I often used to compensate for the lameness of TOP. No more, TOP has been doing steroids between versions and is now more able.
T-SQL joins - No more "WHERE Customers.CustomerID *= Orders.CustomerID" in future versions of SQL Server only the ANSI syntax will be supported (LEFT OUTER JOIN Orders ON Customer.CustomerID = Orders.CustomerID). I've always used ANSI syntax but I've...
I've been messing around a lot with the feature called feature in Microsoft Office SharePoint Server 2007 (MOSS 2007). When encountering problems and not finding my answer in the SDK I've been hitting www.live.com to search for solutions (yeah, ok. sometimes I google to, but live is getting quite good in my opinion).
Anyway, when ever I search I seem to hit Ton Stegman's blog. Which I found to be really good when it comes to working with moss.
Good post by Agnus Logan on how to pitch MOSS to customers. So I find it when I need it.
This summer I've been reading The Pragmatic Programmer by Andy Hunt and David Thomas. And there is nothing else to do but to join the masses of appraisers. It's a really good read. The stuff these boys introduce and advocates is good. The only thing I really found my self disagreeing to was the part about writing your own domain specific compiler for the domain you're working in (I'm referring to the Domain Languages section in Chapter 2), seems to me there can be a maintenance trap there. But that's just a gut feeling and nothing empiric. To be totally honest...
Just returned from TechReady3 in Seattle. Me being a Information Worker consultant with Microsoft I focused on the upcoming Office Systems 2007 release and mostly on SharePoint v3 and Microsoft Office SharePoint Server 2007 (MOSS 2007). The reason it's called MOSS is because it grows on you.... :D OK, maybe not the best joke.
There is a lot of new good stuff coming in this release. First of all it's features asked for by clients (and us working with the products), such a recycle bin and Item level security in SharePoint and so on. The SharePoint UI is now restructured to be a...
Right now I'm reading a, so far, good article on the MVP pattern. The article Model View Presenter at MSDN Mag. The author is taking a TDD approach and the first test he writes looks like this:
[Test]
publicvoid ShouldLoadListOfCustomersOnInitialize()
{
mockery = new Mockery();
ICustomerTask mockCustomerTask =
mockery.NewMock<ICustomerTask>();
IViewCustomerView mockViewCustomerView =
mockery.NewMock<IViewCustomerView>();
ILookupList mockCustomerLookupList =
mockery.NewMock<ILookupList>();
ViewCustomerPresenter presenter =
...
Quite a while ago I wrote a post about Obvious API's. To solve that problem I "Cloned" an XmlDocument object by creating a new and inserting the xml string from the original object. I was not at all satisfied with that solution but with a deadline around the corner and a working solution. Hey what can I say, I left it that way.
XmlDocument xmlDoc =new XmlDocument();
xmlDoc.LoadXml(xmlDocIn.OuterXml);
Just the other day I was fooling around with .Net Framework 2.0 and needed to clone an object that didn't expose a clone method and that I had not written my self. So after...
This is cool, Microsoft Robotics Studio:
"Microsoft announces the Microsoft Robotics Studio, which offers end-to-end robotics development environment customer technical preview for hobbyist, academic, and commercial developers."
I have no idea how to persuade my wife that we need to fit a Lego robot into the household budget though :).
MTPS (Microsoft/TechNet Publishing System) is looking good. Why not build man pages of msdn using it?
A new initiative from Microsoft to support open source development. Ment to replace GotDotNet in time I guess (and it's about time to) check out CodePlex! With flag ships like NUnit! Also read Cory Foy's post about it.
I have many a times wondered what the Debug=True/False actually does, well Tess answers that question in: ASP.NET Memory: If your application is in production. then why is debug=true
Nice collection of samlple code for Visual Studio 2005 both in C# an VB.Net. http://msdn.microsoft.com/vstudio/downloads/101samples/default.aspx. The samples include:
Changing ACL (Access Control Lists) on files
Console Enhancements including buffer control, simple animations and colors
Downloading files using FTP (File Transfer Protocol)
Network Programming including PING, UDP, and TCP network statistics
Using the new Stopwatch class to measure time
Compressing and decompressing files in the GZip format
Retrieving Drive Information
Using Generic Collections
Creating Regular Expressions to parse text
Building a tracing infrastructure to track errors and application performance
Controlling cache policies with the new System.Net.Cache namespace
Creating a process viewer
Creating a...
I needed to unit test a method that retrives a value from a custom property on a Microsoft Content Management Server posting. This is how I did it:[Test]
public void GetLanguage_GetLanguageFromPosting()
{
using(CmsApplicationContext appCtx = new CmsApplicationContext())
{
appCtx.AuthenticateAsCurrentUser( PublishingMode.Update);
try
{
Template templ = appCtx.Searches.GetByGuid ("{8DD8B72A-31B7-495B-80F9-1319FAA78BF2}") as Template;
...
If you've been working with Microsoft Virtual PC you probably noted that the virtual hard disks (.vhd files) tend to bulk out on your host drive. So here is a little tip to help with this, that I just discovered.
From within your guest OS, Capture ISO... and point to C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\Virtual Disk Precompactor.iso
When AutoPlay starts up the iso, you'll get a dialog asking you if you want to prepare the virtual hard disk for compaction. Which you of course want to
When that is done, follow the instructions and shut down the guest OS
From you host OS,...
Microsoft Content Management Server 2002: Security Best Practises now available at: http://www.microsoft.com/downloads/details.aspx?FamilyId=473BEA55-08C1-439E-BA7F-698E5EC343ED&displaylang=en.
Overview:
This download consists of a security white paper and the 'Minimum permissions' batch script. The white paper explains how IT administrators can apply security best practices to Microsoft Content Management Server (MCMS) 2002 Service Pack 1a (SP1a) environments. It includes sections on MCMS security fundamentals; securing MCMS 2002 environments; advanced security information such as port numbers, minimum NTFS, and registry permissions; script samples; and links to additional information. This advanced level paper assumes readers are familiar with the fundamentals of MCMS, Active Directory, and Microsoft Windows Server 2003....
Very often when starting out a new project with a backend database I have usally forgotten exaclty how to compose a connetion string. So, what do I do?
Create an emtpy text file someware, reneame it to .udl (instead of .txt). Open it up by double-clicking it and use the dialog to get your connection up an running.
And then just open it up in your favorite text editor and there you have your connection string. You probably have to clean it up a little.
As I wrote in my previous post I changed my blogging software. In order to migrate all posts and comments from my previous blog i wrote a little program to do it. I did not read a lot of documentation on how to do this, strictly a trail and error approach.
I started out by looking for what web services the different blog systems exposed by doing a file search for *.asmx and just pointing my browser to then to have a look at the API's.
For dasBlog the one that cauth my eye was /SyndicationService.asmx and for SubText it was the...
I've latly been working on a MCMS 2002 project where one of the primary gools have
been to make the public part of the site accessable following WAI
recomendations. So in order to do that I went for Xhtml
1.0 Transitional. The ActiveX content editor shipping with MCMS 2002 is not compliant
with xhtml standard (I secretly wonder if it's compliant with any html standard).
It does stuff like...
How do you sqeeze every little bit of performance out of your VPC? Well, here's a
nice post by Andrew Connell on the subject.
Nice little article if you wanna space out
in using keyboard shortcuts in Visual Studio .Net:
Ask The Pros: Keyboard Bashing
With The Pros
This is an issue that I been wondering about
for years, why is there no intellisense for Sql code in Visual Studio (later version).
I mean it's an amazing tool with a lot of useful stuff in it. So how hard could it
be... Ok, it's easy to complain.
Anyway, now there seems to be a Visual studio plug-in on it's way solving this. Check
out SqlAssist!
Helps with table names, column names, snippets and more.intellisenseintelligenceinterlinesindolenceintoleranceEdit...Revert
to "intellisence"SqSalSolSqqSq'sEdit...Ignore
...
Sony Reader -
Is it the death of the pocket book? Probably not, but pretty cool.Project Elixir
Source Code - Microsoft releases the source code of project elixir. A VSTO Outlook
add-in witch deals with integrating data from Microsoft CRM into Outlook.Decorate
a WebControl - Good post by Phil Haack on "Using a Decorator to Hook Into A WebControl's
Rendering...
Everytime I get the "A potentially dangerous Request.Form value was detected from
the client"-error I seem to spend a couple of minutes to find the name of the web.config
property to allow posts containing HTML-tags. So I'm just gonna put it here so I know
where to find it the next time.
<configuration>
<system .Web>
<pages validateRequest="false" />
...
So guess what, still raining in Seattle. Who'd guess.
Anyway, I'll try to wrap up some of my experiences here.
First's day's keynote at TechReady was held by Steve Ballmer the CEO of Microsoft.
This was an amazing event to witness. Man, the guy knows how to handle a crowd! Action,
energy and a clear message! Mixed up with one or two jokes. I feel privileged to have
...
Microsoft listens to criticism and have removed the
tdd page I wrote about in this post.
The bad votes on the page tell a pretty clear tail...
It's been spreading trough out the blog sphere. Microsoft released a set of guidelines
for test driven development, witch can be found here.
I think it's good Microsoft takes test driven development for real, but these guidelines
simply aren't test driven development in my eyes. I think you should write
one test, make it pass and use the experience and learnings from that when you write
you nest test....
I have not gotten around to trying out Microsoft Visual Team System yet, but for you
who have and like SCRUM. This Beta 1 release of a Scrum
plug-in for Microsoft Visual Studio Team System might be something of interest.
Let me know if you try it and what you think about it, I'm curious.
Always put the owner in a stored procedure the call: dbo.someStoreProc.
http://www.robincurry.org/blog/ASPNETSQLPerformanceAdvicePrefaceCallsToStoredProcsWithOwnerName.aspx
This has probably affected some of the apps I've built.
Seems Microsoft added a little command line tool for pre-compiling ASP.NET applications
in ASP.NET 2.0.
Nice not to have to write a little app that fires up a bunch of threads and does a
lot of WebRequest.GetUrl() calls just to hit all the ASP.NET pages after deployment
in the production environment. Plus it seems to be able to simplify "X-Copy" deployment
a great deal. You can...
Nice post of Scott C. Reynolds on Generics in
C# 2.0 (yeah, I know everybody is talking about C# 3.0 now). It's a very basic
description to get you started, so if you're looking for in-dept stuff this is NOT
it.
Found a, for me, new intresting agile related blog: Cory
Foy [via Roy Osherove].
I haven't exactly spammed this blog over the last couple of weeks, have I. The reason
for that is that I'm about to get married soon so I'm planning my own wedding, helping
a couple of friends with theirs and we have a new project at work, my client is trying
to get a new CRM system up and running in about three weeks(!). Well, here's a little
bit of this and that anyway.
...
My current project is to maintain a range of application for a financial/insurance
firm. Trying to sort out a bug in some nasty legacy-code (VB.NET) I just came
across this piece of code:
If objDataReader("ID_QuestionType") = 1 Then ShowQuestion = ShowQuestionType1(ID_Question,
...)If objDataReader("ID_QuestionType") = 2 Then ShowQuestion = ShowQuestionType2(ID_Question,
...)If objDataReader("ID_QuestionType") = 3 Then ShowQuestion = ShowQuestionType3(ID_Question,
...)If objDataReader("ID_QuestionType") = 4 Then ShowQuestion = ShowQuestionType4(ID_Question,
...
July in Sweden is a month when almost everyone (except me) is on vacation and Sweden
takes a break for a while. However working during this period is actually pretty sweet.
I get time to do things I been putting off all year, all those low priority issues.
OK, so it's quite depressing to when all your friends are on holiday. Anyway started
writing a blog post about a TDD revelation I had a while...
Started out fair enough. Installed Microsoft SharePoint Portal Server to learn a little
and take it for a spin. Realized when I installed it that I accidentally installed
the MSDE along with it, figure I don't need it sense I already have a SQL server.
So I start uninstalling, no problems uninstalling in the MSDE and the WSS uninstalls
without complaining. At last I'm just going to uninstall SharePoint Portal Server.
...
I'm just starting out with
dasBlog (and blogging to as a matter of fact). dasBlog where apealing to me because
there is no database needed, a real simple install. However I ran into a little problem
trying to access the comments page I got an exception:System.NullReferenceException:
Object reference not set to an instance of an object.
at newtelligence.DasBlog.Web.CommentViewBox.Page_Load(Object sender, EventArgs e)
...
Sat down today trying to get some legacy code under tests. I started out with a fairly
simple test... I taught.
[Test]publicvoid XmlGetsBiggerWhenCustomerInformationIsProvidedTest()
{
XmlDocument inXmlDoc =new XmlDocument();
inXmlDoc.LoadXml(SetUp_GetInXml());
CustomerFetcher customerFetcher =new CustomerFetcher();
XmlDocument outXmlDoc = customerFetcher.PopulateXml(inXmlDoc);
Assert.IsTrue(outXmlDoc.InnerXml.Length > inXmlDoc.InnerXml.Length);
...