# Wednesday, August 15, 2007

For a limited time, members of CSharpZealot.com have access to some free Silverlight training content!  Here's how:
Easy!

Also, I'm impressed at how well the InnerWorkings bits integrate with Visual Studio during the training experience.  You should really check it out.

Now please keep in mind that Web 2.0 (and it's previous incarnation, Web 0.9) supports bi-directional time travel
  • Forward, at a pace of 1 second per second, same as daily life, really; and
  • Backwards at a rate of 20 yrs in, say, about 150 miliseconds.
That means that if you are reading this blog post some time in the future, this offer may be closed.  It's only open for a limited time, so get to it!  Don't be the last guy on the block to not know how to use the MediaElement and VideoBrush in Silverlight!

Mad props (that's what the kids say these days, don't ya know?) to Brian Madsen, btw, for keeping CSharpZealot the place to get your .NET love.

Wednesday, August 15, 2007 6:01:21 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, August 14, 2007
This is Part 2 of a series answering the question:  Where do I start as a programmer:

16/08/2007 update - Fixed links

Historically, programming languages are often introduced with their Hello World example. It is completely trivial but also quite an informative place to start.

A Hello World may look like this, for a .NET Console application:

...in C#

class Program
{
   static void Main(string[] args)
   {
      Console.WriteLine("Hello World");
      Console.ReadLine(); // press Enter to close
   }
}

...in VB.NET

Sub Main()
   Console.WriteLine("Hello world!")
   Console.ReadLine() 'press Enter to close
End Sub

I won’t go into the exact details of this sample, but I will mention that the purpose of this trivial example is to illustrate that you are scripting a conversation between the computer and a program.  Magic does not live here.  Computers are just following instructions.

The value of starting a project on a rich framework like the Microsoft.NET framework is that plenty of the elemental pieces required to construct these scripts are supplied for you and arranged in a discoverable fashion. 

An exhaustive list of the pieces that are supplied in the framework is documented in the MSDN Library that you can install with the Express Editions and also online.

Follow the white rabbit, neo…

Start with some good quality learning guidance focused on Visual Studio:
…and don’t forget the web is littered with good and not so good programming tutorials.

Read other people's source code

The problem with tutorials is that they often leave off some important details in order to keep the example simple, thus you can only go so far reading tutorials.

Reading other people's source code can be very helpful in understaning how a technology is used in practice.  Some sources:
Start a project

Lots of people (ok, me – but probably plenty of others too) need a project to really get the programming juices flowing.  I need a problem to solve; otherwise I’ll just stare at the File -> New dialogue for hours.

What does this mean for beginner programmers?  Don’t think you have to look for problems that are new to science and have never been solved before.  Download.com  probably has hundreds of “note taking” applications, and “home movie database” applications.  The benefit of  starting a project at this stage of your career is not to solve a new problem – it’s what you pick up along the way.

Be generous with the constraints of your project.  Learning works best when it’s fun.  The last thing you need when starting programming is the stress of project constraints!

Start a blog

Grab an account at Blogger or one of the other blogging platforms and record your experiences.

Even if it is just “this is what I learned today” and “this is what I don’t understand today” posts there is still value in blogging:
  1. Blogging forces you to stream your thoughts down into words.  The cathartic effect this can have on your thoughts while learning a technology can hardly be understated. 
  2. Blogging is a great way to open a conversation with other people who are doing the same thing

For blogging on the train?  Try Windows Live Writer, but I often just use Word then copy-and-paste when I get connected again.

Be aware of support:

Of course, the blogosphere has a wealth of information ;-)

Some others:
...and there are literally hunderds more sites on the web of various quality and reputation...

What Else?  I'd love to hear from anyone via comments here on this topic.  What other bits should people go and get for programming on day one.

Listening To:  DAT323 Inside T-SQL (with Itzik Ben-Gan) from Tech.Ed '07.
Tuesday, August 14, 2007 2:14:01 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [3]  | 
A friend of mine dropped me an email that asked the following:

So, I’ve been thinking more and more lately that I should make some better use of my spare brain cycles and train time by learning some coding. Do you have any recommendations for where a total coding newbie with no money and no copy of VS should start?

So I thought I would answer in a series of blog posts.  This is part 1.

The first thing is no money does not mean that you can’t have a copy of Visual Studio

The first thing to do is grab a copy of Visual Studio Express Edition.  These are supprisingly capable cut down versions of the real Visual Studio 2005.

Go for Visual Basic or C# - don’t think C++ or J# are particularly good places to start learning code.  Either is fine.  Really. 

Also, Visual Studio 2008 Express Edition is available in Beta 2 at the time of writing.  Visual Studio 2008 is awesome, but again not the best place to start imho.

Then grab Visual Web Developer Express and SQL Server Express

Also, if you think MCP Certification is on the cards, each MS Press training kit comes with a 90-day copy of Visual Studio Professional.

UPDATE:  There are some additional downloads to consider:

The second thing is no Visual Studio does not mean no .NET programming

#develop, or SharpDevelop is a free, open source development tool for C#, VB.NET and Boo.

It has a couple of limitations, but can be had for a tiny 8.2Mb download and dosen't carry some of the weight of Visual Studio while still keeping some of the look and feel.

Still have some spare bandwidth?

Grab the Windows SDK.  It's probabbly a bit above the beginner level but it represents an execllent reference to what is happening under the hood when you come to need to know.

Grab FxCop (NB: you may have grabbed this as part of the Windows SDK).  FxCop is a tool that looks at your programs and compares them to a set of rules for programming on the .NET framework.  This is a little bit of an advanced topic, but also is a really valuable learning tool for avoiding bad coding habits.

FxCop 101:  The default is to check your code against all the rules.  As a beginner you probabbly don't want this.

Source code control is an important practice.  Even for a single guy on a train.

For source code control I would recommend going with SourceGear Vault which is free for a single named concurrent user.  It's really easy to install and get going.

Unlike SourceSafe, Vault is backed with a SQL Server database for better performance and backup support, and also runs over SSL and can run over the internet.  Additionally it supports an Edit-Merge-Commit usage pattern in addition to SourceSafe’s Checkout-Change-Commit usage pattern – but that is a bit of an advanced topic so don’t get too distracted.  Just know that it’s there for later.

What Else?  I'd love to hear from anyone via comments here on this topic.  What other bits should people go and get for programming on day one.

Listening To:  DAT318 Applied ADO.NET Entities from Tech.Ed '07.

Tuesday, August 14, 2007 1:26:16 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [2]  | 
# Friday, August 10, 2007

So I was talking with Rob Farley at Tech.Ed (Rob, you’re my hero ;-)) and the topic he raised the topic of what if we did not grant *users* access to our SQL Servers, but instead only allowed groups.

Not something I had really thought about much before but This is a really good idea™.

The question that naturally arises is: How do we enforce this with something stronger than “because I said so”.

The good news is that it appears that SQL Server 2008’s Declarative Management Framework (a.k.a. “policies”) can be of assistance here.

Background on the Declarative Management Framework:
  • A Facet is a piece of data about the system that you can use in your policies. 23 Facets are included in the current Katmai CTP.
  • Each Facet can have 2 or 10 or more Properties. It is the properties that are used in your conditions. Facets are logically groupings of properties by SQL Server
  • A Condition is a logical expression about a property or set or properties
  • A Policy is a named instance of a specified Condition with a rule on how it will be enforced (on a schedule, on changes etc).
Step 1: Create a new Condition and call it GroupsExist. Choose the Login facet and the LoginType property. Set it to equal WindowsGroup.

In the case that there are user accounts like .\ASPNET or the ##MS_PolicyExecutionLogin## login that have a legitimate right to be there, list those in the expression as illustrated below.
 

Step 2: Create a new Policy based on the GroupsExist condition and cal it OnlyAllowGroupsNotUsers. Apply it to Server/Login and set it to Enforce as illustrated below.



One of the really cool things is that you can create your policies in a not enabled state, and use the built-in testing harness to get the policy right before enforcing it.

To test a policy in SQL Server Management Studio, right-click on it and choose Test… This will run the policy against the current state of the server and report the details of success or failure.

Now when the policy is disabled, the following statement will do as it is designed.

CREATE LOGIN [MYLAPTOP\SampleUserAccountAccess] FROM WINDOWS GO


However when the policy is Enabled, I am getting the following error, which I assume means I am am on the right track :-)

Msg 10314, Level 16, State 11, Procedure sp_syspolicy_execute_policy, Line 25
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE.

Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.SqlServer.DmfSqlClrWrapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.

Strong name validation failed. (Exception from HRESUL
T: 0x8013141A) ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A) System.Security.SecurityException: System.IO.FileLoadException:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
The statement has been terminated.


I’ll research this message next week, as well as re-do the sameple when back home and connected to AD, and if the results differ I’ll re-post.

...Topic for future blogging: Ensuring consistent policies across several instances of SQL Server. Stay tuned.

Listening To: The dodgy motor in the fridge in my apartment.





Friday, August 10, 2007 8:14:44 AM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [1]  | 
# Tuesday, August 07, 2007



If you are attending and wanna hang out, drop me a line via this blog.

Otherwise, see you next week* :)

* by which time I will be significantly smarter... ;-)

Tuesday, August 07, 2007 12:34:22 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, July 31, 2007
The CLR Add-In Team Blog has just posted a list of the 7 new features that they have included in Visual Studio Orcas2008 Beta 2.

Tuesday, July 31, 2007 11:49:06 AM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, July 26, 2007

(this is just a post that I'm putting out there, when I Googled for the error I got nothing relevant, so this post is dedicated to the future searcher, whoever you may be...)

The error occured on a brand new install of Windows 2003 Server R2 w/ SP2 slipstreamed.  Oddly, this media set had installed another server without error, but anyway the error was:

Setup library netfxocm20.dll could not be loaded, or function UrtOcmProc could not be found.  Contact your system administrator.  The specific error code is 0x7e:

The solution was to reinstall the "R2 bits" (aka. Disk 2) and reboot.

I'm still looking for a log file or event log message or any clue anyware in the system to indicate why it went bad, but don't like my chances...

Thursday, July 26, 2007 5:58:16 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, July 22, 2007

It dawned on me today, why the same old song isn't working for the youth of today...

The message should not be that sex leads to pregnancy, but that sex leads to prams!

Yes, I'm talking about prams, strollers and buggies people!  You're killing me already!  I give in! 

That will be all :-)

Sunday, July 22, 2007 10:24:06 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [1]  | 
# Thursday, July 19, 2007

This is the third of my posts about group policy for web developers [part 1] [part 2], and today's post is a from-the-trenches tail about how you can get 401.1 Access Denied as a result of applying group policy.

Mad props to Jimmie Russ and his post Access Denied 401.1 goes away temporarily after IISRESET, as it was his post that sorted my problem today.

As you will see in his post, it is possible to push out User Rights Assignment policies via a GPO that can define the following rights:

  • Log on as a service
  • Log on as a batch job
  • Allow log on locally
  • Access this computer from the network

The above list may not be complete, but it was these four that caused a problem in my IIS environment.

Two tell-tail signs that this is your problem:

  1. If you run the always awesome AuthDiag utility and it reports that certain local accounts (like IUSR_*) have rights missing, specifically the ones listed above.
  2. When you view the User Rights Assignment in Local Security Settings
    • The above four rights are locked (have a little lock icon instead of the "blue 1s and 0s icon") and are not able to be edited.
    • The above four rights are not granted to our local accounts (again IUSR_* et al)

Again, it may not always be exactly those four - what you are looking for are policies that will not allow your IIS accounts (as listed in the AuthDiag results) to log on.

If I had my time again, I would have cranked up the failed security events and listed them here, but my servers are working again and I like it that way so this can be left as an exercise to the reader :-)

As Jimmie said, the solution is to have these rights not pushed down to your web servers.  This can be by not applying them in your Default Domain Policy, or by putting your web servers in a seperate OU blocking policy inheritance.  If you're not sure, consult an expert.

Thursday, July 19, 2007 4:39:09 PM (AUS Eastern Standard Time, UTC+10:00)  #    Disclaimer  |  Comments [0]  |