Tuesday, February 19, 2013

The Problem Steps Recorder is the solution to the problem

So, my blog has been very quite lately...The reason is simple, I have been buried under mountains of documentation in the planning phase of a new project and didn't feel the need to blog about how to create a PowerPoint presentation or how to properly apply Headings and Citations to a Word document.

With that being said, this project is very exciting and I can't wait to get my hands on a Dev server and go nuts!

So with the beginning of any new project there is excitement, but there is also that little voice in the back of your head that says, "The documentation isn't over! You owe me a "Configuration/Install Guide". Call it what you will, but this jewel of a document is probably every Developers worst nightmare on any project. Inevitably, there is always someone who wants you to record your every move and make sure that there is a document (that no one will likely ever crack open) that they can refer to if they need to build the environment from the ground up.

Now, just because you don't like it or think it is silly, there is some merit to having this document and I can see how it can be important for auditing and supportability in the future.  So enough of the ranting...the real reason I am writing this post is to tell you about something that was just brought to my attention that makes building a Configuration Guide a lot easier.

So, first lets talk about the way we usually do this...open up Word or OneNote and type out, Open this.... (insert Screenshot) Then Click on this (insert Screenshot) then click on this (insert Screenshot) then type this (insert Screenshot)  then....blah blah blah....there has got to be an easier way! Have you ever wish there was a way to record your clicks in screenshots and documented steps? Well here it is...a (very) hidden jem of the Windows 7 operating system! the Problem Steps Recorder!



The Problem Steps Recorder in the Windows 7 operating system is a feature that enables users to record their interactions with an application and provide a detailed screen-by-screen view with accompanying information. 
Since this tool is so hard to find i used it to show you how to find it, here is the result (you may have to download a copy)

If you would rather the short answer just use the search in Windows 7 Start menu to find it by searching for "Record Steps"

Saturday, September 15, 2012

How to: Insert AsemblyFileName in C# Code

Ever get burned by a cached assembly? I just did recently and it was no fun.

There is nothing worse than troubleshooting an issue you have already resolved. In my case I was working on a Custom Retention Policy and after troubleshooting for far longer than I would like to admit, I realized that when I initiated the retention policy date calculation it would work fine (this uses the W3WP.exe process) but when the Expiration Policy Timer Job ran it didn't work as expected (that timer job runs under the context of the OWSTimer.exe) so the OWSTimer had cached my code and was running old code.  I restarted the OWSTimer and just like magic all was well.

So I posed a question to myself, how can I know exactly what version of your code I am running? Sure you can right click on the assembly and check the properties there but that doesn't mean that is what the timer service is running for example. Entering a version number in your code can be a great way of ensuring that you are running the latest and (hopefully greatest) version of your code.

This is what I ended up with...this will take the AssemblyFileVersion from the AssemblyInfo.cs file:
   1: using System.Reflection;
   2: ...
   3:
   4: Version fileVersion = new Version("0.0.0.0");
   5: AssemblyFileVersionAttribute[] fileVersionAttributes = (AssemblyFileVersionAttribute[])Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true);
   6: if (fileVersionAttributes != null && fileVersionAttributes.Length > 0)
   7: {
   8:     fileVersion = new Version(fileVersionAttributes[0].Version);
   9: }
  10: string workflowVersion = "Workflow Version: " + fileVersion;
You can then take that string and output it in a ULS Log entry for example.

Next step...Use TFS to increment the AssemblyFileVersion durring the build ;)

Wednesday, August 29, 2012

Unable to find the default edit form for list...

So Exporting a Site as a Template and Importing it into Visual Studio can be very useful but only if it works!

I was trying to use this method to create a List and a Library Instance so I could include it into my existing solution.  I did this and it appeared as though everything worked well until I tried to upload a document in the library or create a new list item...then I would get a nasty error about
"Unable to find the default edit form for list My List"
So I looked back in the definition and for the list there was this SharePoint Module inside that was named 'Listslist_name_here_pages'and had a Elements.xml inside it with some information about the DispForm, NewForm and EditForm...

Perfect, so for the list I included this module just as it was in the other solution and low and behold it worked...but then the Library didn't have a module inside it...WTF!!! Then some more snooping lead me to see that there was a Modules folder that had 4 Modules with the corresponding names each with their own different Elements.xml files!
LibraryNameForms_1033_STS_doctemp_word
LibraryNameForms_Features_DocumentLibrary_doclib
LibraryNameForms_pages
LibraryNameFormsMy Custom ContentType_1033_STS_doctemp_word
NASTY!!!

So, being a slave to SharePoint I set out to duplicate these four modules just as they were in the imported solution...no dice...but then I got to thinking about how this works and I snooped into the Scheme.xml of the list instance and found this....
<Forms />
What?!? that's not right...so I blew away all my precious modules I worked so hard on and switched the above one line in the Scheme.xml for this...
<Forms>
  <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
  <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
WOW! Its magic! just like It should be...and a much nicer, cleaner solution.

More information about the Scheme.xml can be found here

Tuesday, August 21, 2012

SharePoint 2010 Products Configuration Wizard "Configuration Failed"

Ever spent a full day (or more) trying to get SharePoint 2010 Products Configuration Wizard to work properly?

It seems like every time I have to run this thing it fails with that lovely "Configuration Failed" error message...and this is of course after 15-20 min and 92.57% or whatever random percentage it pulls out of the air.

You can dig through the logs, the "Upgrade-datestamp-timestamp-randomnumber-error.log" log file often has much more informative information in it that the "PCDiagnostics_datestamp_timestamp_randomnumber.log" that the wizard recommends.

So, after that then what?

Never fear, Command Prompt is here!

Run this command from a SharePoint 2010 Management Shell prompt and 9 times out of 10 it will work...I don't know why i don't just do this to start with.
PSCONFIG.EXE -cmd upgrade -inplace b2b -force
there are many different switches you can add to this command all of which may or may not help but this is the one that i use the most.

Tuesday, July 31, 2012

HEY!!! Who changed my Helper.dll?

Ever want to share a class in Visual Studio without having the overhead of the good 'ol "Helper.dll"?

Try this instead...
Adding an Existing Item as a Link

It is a very rarely used and under appreciated feature of Visual Studio that I didn't know existed until recently.

Here is why this is good:
  • You have less DLL's
  • You still have the ability to share classes.
  • When you compile your code you always have the latest version of the class unlike a copy of the class.
  • Once you compile, that build will always have that version of the class until you build again.
  • Sharing Is Caring...OK, OK, I am done


Downfalls:
  • I can't think of one can you?

Thanks to my coworker and this blog post for helping me realize this possibility.

Friday, July 27, 2012

Ode to SharePoint Designer

Just a little fun here...
You have the right to use SharePoint Designer,
Anything you save or modify will not be backed up.
Some unexpected results are to be expected.
If you cannot afford a Developer, then you may not wish to proceed.
Do you understand these flaws as I have described them to you?
Just kidding SPD...but seriously, stop trying to help...if I wanted your silly __designer:Preview tags then i would ask for them.


If you got here via search looking for answers I am sorry...try these sites:
SharePoint Designer 2010 inserts "__designer:Preview" and "__designer:Values" attributes upon reopening of Master Pages
Sharepoint Designer 2010 adding/generating __designer preview tags – a fix to solve this issue

SharePoint 2010 Event ID 6482 Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance

Have you ever seen this error in your ULS and wondered what it was?

SharePoint 2010 Event ID 6482 Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance
I used to always ignore it because although it showed up once a minute in the logs SharePoint Search worked fine.


I got curious about it and decided to do some digging which lead me to this great article by Jeff DeVerter that explained what the issue was and how to resolve it.


And now thanks to Jeff, my ULS has been error free for 3 days!