jump to navigation

Yet Another VS2010 Overview June 18, 2010

Posted by codinglifestyle in ASP.NET, C#, Parallelism, Visual Studio 2010.
add a comment

Today I attended a mediocre presentation by Paul Fallen which looked stellar compared to the atrocious overview put on at the Galway VS2010 Launch Event.  Paul had the look of a man who had seen these slides many times and glossed over them at speed.  In fairness, he was using the same presentation deck I’ve seen since TechEd 2008.  I think we had all seen several flavours of this overview by this time, so nobody seemed to mind.  Below are the few snippets of information to add to the smorgasbord of other snippets I’ve gleaned from other talks of this nature.

Please click here for more comprehensive posts earlier on VS2010.

Here is the VS2010 Training Kit which was used in the demos.

  • Common Language Runtime
    • Latest version is CLR 4 (to go with .NET 4).
    • Previous version of CLR 2 encompassed .NET 2, 3, 3.5, 3.5SP1
    • Implications
      • App pool .NET Framework version
      • Incompatibilities running CLR frameworks side by side within same process
        • Think 3 COM objects accessing Outlook all using CLR1, 2, and 4
  • Managed Extensibility Framework (MEF)
    • Library in .NET that enables greater reuse of applications and components
  • VS2010 & C# 4.0
    • IDE
      • WPF editor – Ctrl + mouse wheel to zoom.  Handy for presentations
        • Box select (like command prompt selection)
      • Breakpoint labelling, import/export, Intellitrace (covered below)
      • Code navigation improvements (Ctrl + , and Ctrl + – for back)
      • Call Hierarchy
        • Allows you to visualize all calls to and from a selected method, property, or constructor
      • Improved Intellisense
        • Greatly improved javascript intellisense
        • Support for camel case
        • Can toggle (Ctrl + Space) between suggestive and consume first mode (handy for TDD)
      • Test run record, fast forward
      • Better multi-monitor support, docking enhancements
      • Tracking requirements and tasks as work items
    • Better control over ClientID
    • Routing moved out from MVP to general ASP.NET
    • Optional and named parameters
    • Improved website publishing, ClickOnce (see prev. posts)
  • Parallelism
    • Pillars
      • Task Parallel Library (TPL)
        • He didn’t touch at all on the new task concept
      • Parallel LINQ (PLINQ)
        • These are the extension methods to LINQ to turn query operators in to parallel operations.
          • var matches = from person in people.AsParallel()
          •               where person.FirstName == “Bob”
          •               select person;
      • System.Threading significant updates
      • Coordination Data Structures (CDS)
        • Lightweight and scalable thread-safe data structures and synchronization primitives
    • Toolset
      • Debugger: record and visualize threads
      • Visualizer: View multiple stacks
      • IntelliTrace – new capability to record execution, play it backwards and forwards, even email it to another engineer and have them reproduce the problem on their box
    • Other
      • Eventual depreciation of ThreadPool as higher level abstractions layer atop toolkit?
      • Unified cancellation using cancellation token
  • Dynamic Language Runtime (DLR)
    • New feature in CLR 4
    • Major new feature in C# 4 is dynamic type
      • What Linq was to C# 3.5
    • Adds shared dynamic type system, standard hosting model and support to make it easy to generate fast dynamic code
    • Big boost working with COM: type equivalence, embedded interop, managed marshalling
  • Windows Communication Framework (WCF)
    • Service discovery
      • Easier to discover endpoints
      • Imagine an IM chat program or devices that come and go
    • REST support via WCF WebHttp Services
      • Available in the code gallery templates
  •  

    A day with The Gu! MVC 2, VS2010 and ASP.NET v4.0 September 29, 2009

    Posted by codinglifestyle in ASP.NET, C#, jQuery, linq, Visual Studio 2010.
    Tags: , , ,
    2 comments

    Yesterday I went to Dublin to attend a talk by Scott Guthrie. I knew from reputation Scott was a good speaker so it was great to see him in action. I think most of the Microsoft development world is familiar with Scott’s blog. I’ve exchanged emails with him in the past and he has always done a great job following up. He is a very down to earth guy, very at ease at the podium, and very comfortable the material.

    We started the talk with a beginner’s look at MVC 2 and then looked at .NET v4 and VS 2010. Some of this information was a recap of TechEd (see my earlier post), but there was plenty of new information which I’ll recap here.

    MVC 2

    Scott’s talk was about some of the improvements of the next version of MVC which will be baked in to VS2010. But thankfully, he covered the whole concept in a very demonstration-oriented way. He built upon each concept in a way that left me with a good grasp of the basics.

    First, he reiterated that webforms is not going away. MVC is just an alternative presentation layer built upon the same core .NET libraries we know and love. Because there is no designer, no .NET controls, and no code behind (as such) you are much more in control of the generated HTML.

    What MVC offers is that control, URL mapping, js integration, and testability. If you’ve ever worked on a messy web app and wished for more structure MVC may be for you. It offers a clean separation of your data layer (model), your html (view), and your business logic (controller).

    Right, enough of this verbose carrying-on, time for bullet points!

    · MVC 1 was an extra for VS2008 built on ASP.NET v3.5. MVC2 will be baked in to VS2010 and built on ASP.NET v4.0. It will be backwards compatible with MVC1 apps so upgrades should be a snap.

    · Controller

    o URL Mapping – this is not just a cool feature but fundamental to MVC

    § http://localhost/galway maps to a controller class called galway

    · .index is the default action method

    § http://localhost/galway/hooker maps to an action method inside controller Galway

    § http://localhost/galway/hooker/beer maps to the action method hooker and passes the string parameter “beer”. Note this is an alternative to query string parameters.

    · These parameters can be strongly typed to string, int, even classes

    § Routing rules go in to gloal.asax.cs

    · Operates like an HTTPHandler but is baked in to ASP.NET

    · Order routing rules as you see fit. One falls through to another and ultimately to a default

    · Can use regular expressions and constraints in your rules

    o We can start playing with a controller without a View or Model and directly return some html from controller (think webservice)

    o Controller action methods can return an action result type to return a View, redirect, etc.

    o To communicate with View we can

    § store information in a ViewData[“key”] dictionary to pass to View

    § store information in a Model and pass this class to View

    o Action Filters decorator attributes can be specified on the controller class or an action method to specify which roles / authorization required to use

    o Tip: Use a service layer to keep direct data layer queries out of controller

    · View

    o Offers separation of UI from business logic and just renders the UI

    o Remember, no designer or ASP.NET controls. Just you, html, and <%inline code%>.

    o HTML. Helper with many built-in templates to generate common controls like checkboxes and textboxes with validation

    § Create your own View templates to have custom scaffolding like a table for a DB list

    o Html.EditorFor gives Linq type intellisense to meaning we aren’t binding to a “string” in our model

    § Smart in that Booleans render as checkboxes, etc.

    § EditorTemplates can be used to custom render anything can be shared across entire site or used for just one View

    o Html.DisplayFor gives read-only view of data

    · Model

    o A data entity with logic.

    § Can be LinetoSQL, ADO.NET, your own entity class, whatever

    o Can decorate properties with attributes to specify common validators

    § Required, range, etc.

    § Very powerful, dynamic, should greatly ease pain of validating form data

    § Automatically adds a CSS class you can customize to get a red background, whatever

    § Can have server and client side validation

    · Client side requires an extra js plug-in but worked seamlessly in demo

    · Unit testing is crucial component of MVC and a test project is automatically created for you with every MVC website

    o Use AAA method

    § Arrange

    · Create a controller

    § Act

    · Get the result of (controller.Index(0) as ViewResult)

    § Assert

    · Assert if result.IsNotNull

    o Dependency injection

    § In the constructor pass DB service layer or fake data. Use an interface for flexibility.

    VS2010 & .NET v4.0

    · Beta 2 out shortly

    · IDE improvements

    o Ctrl-, – quick nav via types

    o Highlight all references

    o Tip: Download CodeRush Xpress for these features in VS2008)

    · Better intellisense support

    o camel case (i.e. DB matches DataBind)

    o Matching (i.e. bind matches DataBind)

    o Consume first mode for TDD (test driven development)

    § Ctrl + Alt + Space to toggle

    o Much improved javascript support

    § XML documentation (place under function()) for better intellisense for your own libraries

    · Debug History and dumping a crash covered again (see previous post)

    · .NET 4 is a new CLR unlike 3.0 and 3.5

    o In IIS you will see v4.0 as a selectable framework

    · Upgrading to VS2010 hopefully just changes solution file (like VS2005 > VS2008) so painless enough to upgrade

    · Multi-target support from .NET v2.0 on up

    · Lots of project templates including a new online template gallery (web starter kits?)

    · Controls to have ClientIDMode property

    o Static – is what it is. Call it “bob” and you are guaranteed to get document.getElementByid(“bob”)

    o Predictable – new default… no more ctrl001_ prefixing

    o Auto – current

    o Inherit

    · CSS rendering support

    o Big upgrades including alternatives to tables for .NET controls

    · ViewState – off by default. Force developers to think when we really need it.

    · URL routing like MVC for WebForms (connotical)

    · SEO (Search Engine Optimization)

    o Page.Description and Page.Keywords to generate <meta> tags

    § Idea: Place in master page, tie-in to DB, allow client to change as required

    o New SEO plug-in for II7 will crawl site and indentify issues that reduce search relevancy

    § Can increase search traffic 30-40%

    · ScriptManager support CDN allowing you to specify URL for AJAX and jQuery direct from http://ajax.microsoft.com. Will actually phantom redirect to very local source but browser histories across many site will use standard Microsoft url meaning high probability of being cached

    · New controls

    o QueryExtender search control – search a grid

    o Chart control

    · Validation like MVC for GridView, FormView, ListView

    o Auto reflect on class for validation decorator attributes and dynamically render validators with client and server-side validation

    · Output/object cache providers (aka customizable I’m sure)

    · Pre-start application

    o Keep your application up, cached, and ready vs. IIS default behavior which shuts down when not in use

    · Performance monitoring

    · <%: Html encoded string %>

    · Deployment (see previous post)

     

    Well that wraps it up.  Please see my earlier post from Tech-Ed and download my PowerPoint presentation which covers a lot of the upcoming features in VS2010.

    Code Snippets – List of C# snippets in VS2008 May 6, 2009

    Posted by codinglifestyle in C#, CodeProject, Visual Studio, Visual Studio 2010.
    Tags: , , ,
    add a comment

    In VS2010 we are told to expect a lot more code snippets.  To be honest, I don’t use them much but watching the demo I told myself it was time to give them another look.  Sometimes I get a great feeling of productivity in hammering out for loop templates and properties and tell myself who needs snippets?  But there is a lot of power there, and its going even further in VS2010.

    My problems is I can never remember which code snippets are there.  I occassionaly see them in Intellisense, but there is so much there it’s hard to pick them out.  More than once I’ve carefully gone through the intellisense list trying to pound the useful ones in to my brain.

    I decided to do a quick search for a list of code snippets in VS2008 for C#.  Surely I can’t be the first who just wants a simple list, right?  I came across Francesco’s blog who posted the code to iterate through your snippets and output them.  A quick change to update it for VS2008, C#, and to output a comma delimited line per snippet, then a paste in to Word, and Convert Text to Table (by comma) and voila!

    List of Code Snippets in VS2008 for C#

    #if Code snippet for #if
    #region Code snippet for #region
    attribute Code snippet for attribute using recommended pattern
    checked Code snippet for checked block
    class Code snippet for class
    ctor Code snippet for constructor
    ~ Code snippet for destructor
    cw Code snippet for Console.WriteLine
    do Code snippet for do…while loop
    else Code snippet for else statement
    enum Code snippet for enum
    equals Code snippet for implementing Equals() according to guidelines
    exception Code snippet for exception
    for Code snippet for ‘for’ loop
    foreach Code snippet for foreach statement
    forr Code snippet for reverse ‘for’ loop
    if Code snippet for if statement
    indexer Code snippet for indexer
    interface Code snippet for interface
    invoke Code snippet for safely invoking an event
    iterator Code snippet for a simple iterator
    iterindex Code snippet for ‘named’ iterator/indexer pair using a nested class
    lock Code snippet for lock statement
    mbox Code snippet for MessageBox.Show
    namespace Code snippet for namespace
    prop Code snippet for an automatically implemented property
    propg Code snippet for an automatically implemented property with a ‘get’ access or and a private ‘set’ accessor
    sim Code snippet for int Main()
    struct Code snippet for struct
    svm Code snippet for ‘void Main’ method
    switch Code snippet for switch statement
    try Code snippet for try catch
    tryf Code snippet for try finally
    unchecked Code snippet for unchecked block
    unsafe Code snippet for unsafe statement
    using Code snippet for using statement
    while Code snippet for while loop

    You can see snippet’s keyword typically matches the operator.  So next time you type for or while or try remember to hit TAB-TAB to expand the snippet.  Next time we’ll look at making your own code snippets.

    Visual Studio 2010 and C# v4.0 Technology Preview Presentation April 29, 2009

    Posted by codinglifestyle in C#, Visual Studio 2010.
    Tags: , , , ,
    1 comment so far

    This is an expansion on my previous post on Tech-Ed 2008 which I attended last November’s in Barcelona.  As a condition for attending I gave a talk to my company, Storm Technology.  I put a good amount of effort to the attached PowerPoint presentation for my talk.  The company has graciously allowed me to distribute it which is great because all the information is relevant and up to date.  If you are giving a similar presentation and/or want a template for a good place to start you are welcome to my slides.

    https://codinglifestyle.files.wordpress.com/2009/04/storm_teched2008.pptx

    Enjoy!

    Tech-ed 2008 November 17, 2008

    Posted by codinglifestyle in ASP.NET, C#, IIS, jQuery, Parallelism, Security, SharePoint, Visual Studio 2010.
    Tags: , , , , , , , , , , , , , , , , ,
    3 comments

    Last week I had the opportunity to attend TechEd 2008.  I have compiled a set of notes from the keynote and sessions I attended below.  Most of the information presented at these conferences is not really instructive for addressing today’s problems but talks about future problems and the technologies we will use to address them.  There are some interesting technologies coming down the pipe in the not so distant future and these notes may provide you with enough information to google more information about the topics which interest you.

     

    I skipped a lot of older information about the VS2008 release, C# v3.0, and Linq which can all be found here.

     

    Keynote

    ·         Testing Activity Center application

    o   Pillar: No more no-repro

    o   Generate test cases that tester can click off

    o   Bug recording including video, call stack, system information

    o   Generate a bug integrated in to Team System

    §  Can start up debugger and reproduce tester’s scenario

    §  Captures line of code, call stack, everything

    ·         Code buffering

    o   Method shows history of changes (graphically too)

    o   Integrates SCC versions in to IDE

    ·         MVC design pattern

    o   Model                   =              data

    o   View                     =              web page / UI

    o   Controller             =              logic

    ·         SharePoint Integration

    o   Server explorer includes lists, ect

    o   Webpart template automatically contains ascx control for design support

    o   SharePoint LINQ

    o   List Event wizard

    §  Auto-generate XML for site def??

    ·         Performance Profiler

    o   Pillar: Leverage multi-core systems

    o   See which method is taking time and core utilization

    §  Graphically shows core usage including drill down

    ·         Will help with concurrency, deadlock debugging, ect

    VS2008 Service Pack 1 Overview

    ·         ADO.NET Entity Framework release

    o   Very similar to Linq To SQL

    o   Generate data model

    §  conceptual model static (actual db) model

    o   Data Services

    §  Data centric abstraction over web services (WFC)

    §  Exposes and takes IQueryable so datasets very easy to work with in a LINQ like way

    §  Routing lets URI act like a Linq query

    ·         http://Root/my.svc/Customers/35/FirstName

    o   Dynamic Data

    §  Given a data model will create aspx accessibility to defined objects

    ·         Security: all objects off by default but can dynamically access entire data model

    ·         Allow CRUD access via ASPX templates applied to all objects

    o   CRUD = create, read, update, delete

    o   Can create individual page for certain object

    o   Can customize template to affect all objects

    ·         Ajax / other enhancements

    o   Ajax

    §  History Points

    ·         Addresses problem that users lose ability to hit back button

    §  Script combining

    ·         To improve performance allows to dynamically combine js libraries

    o   Improves javascript intellisense

    o   Improves web designer performance (bugs/regressions addressed)

    C# v4.0

    ·         History

    o   V1 – Managed Code big emphasis

    o   V2 – Generics; finished the language

    o   V3 – LINQ

    ·         Pillars

    o   Declarative programming: we are moving from “what?” to “how?”

    §  LINQ is an example of this

    o   Concurrency: Some of the parallelism extensions we will be getting

    o   Co-Evolution: VB and C# will more closely evolve together vs. Features hitting languages at different times

    o   Static vs. Dynamic Languages: aren’t necessarily a dichotomy

    §  Static: C++, C#, VB – anything compiles

    §  Dynamic: IronRuby, IronPython, Javascript

    ·         New keyword: dynamic

    o   Call any method of a dynamic object and the compiler won’t complain

    §  No intellisense possible

    §  Will call during runtime

    §  i.e.

    ·         dynamic calc = GetCalculator();

    ·         calc.Add(10,20);   //We know nothing about calc object

    §  Lots of power to  be explored here

    o   Optional Parameters

    §  Like in C++ (and apparently VB)

    §  Named parameters

    ·         Can also skip optional parameters

    ·         Public StreamReader OpenTextFile(string sFile, bool bReadOnly = true, int nBufferSize = 1024);

    ·         sr = OpenTextFile(“foo.txt”, buffersize:4096);

    o   COM Interoperability

    §  No more “ref dummy”!

    ·         Will get: doc.SaveAs(“Test.docx”);  //Winword saveas

    ·         Versus:   doc.SaveAs(“Test.docx”, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy, ref dummy);

    §  Automatic dynamic mapping so less unnecessary casting

    §  Interop type embedding

    ·         No more bringing in PIA

    o   Safe Co and Contra-variance

    o   Compiler as a service

    §  Compiler black box opened up to be used and extended

    §  In example created a command window with C#> prompt

    ·         Was able to define variables, functions, ect like in IronPython

    Ajax v4.0

    ·         Introduction

    o   Web app definition

    §  Web site is a static collection of pages (such a BBC news)

    §  Web application is something which replaces a traditional windows app

    o    Traditional Server-Side ASP.NET vs. AJAX

    §  Pros

    ·         Safe: Guaranteed browser compatibility

    ·         Powerful: All the power of a .NET language in code-behind

    §  Cons

    ·         Response: User must wait for postback

    ·         Performance: All page content rendered for each interaction

    ·         Update Panels: Use Wisely

    o   An update panel uses sneaky postbacks so while it looks better it is still as bad as traditional server side asp.net

    o   Don’t wrap an entire page in an update panel

    §  Wrap the smallest region required

    §  Use triggers to set what controls will fire a sneaky postback

    o   Turn ViewState OFF

    §  Down the line this will not be on by default

    §  We often send a lot of unnecessary information over the wire in ViewState

    ·         Ajax Calls (Services)

    o   Consider using an Ajax control to update data as needed

    o   Calling a web service from javascript is not considered dangerous or bad practice

    o   Example

    §  Have a datagrid with postback bound to a dropdown list.  Instead of a postback on ddlist use Ajax call

    ·         Instead of a datagrid use a straight html table

    ·         Via script we make a call to the web service

    ·         Use stringbuilder to format return to build up new rows

    §  Kinda horrible!  Too much mixing of mark-up and script

    ·         Client Side Controls

    o   Clean way of separating Ajax related script from the web page

    o   Allows you to bind to Ajax calls in a template way

    o   Example

    §  From above we now separate js in to a client side control which is now cleanly referenced on our web page

    ·         Declarative Client Side Controls

    o   “X” in XML stands for extensible; but not often extended!

    o   Use XML to bring in namespaces like System and DataView

    o   Can define a datagrid purely in html by adding attributes to the

    tag in a table

    ·         Fail over

    o   Problem with Ajax is not it is not always supported for reasons of accessibility, search engines, or disabled javascript (mobile devices)

    o   Does require double implementation of Ajax and traditional solution but it is an option when needed

    ·         New features in SP1

    o   Back button support!

    §  As of VS2008 SP1 Ajax now has back button support

    §  ScriptManager property EnableHistory=true and onNavigate event

    §  AddHistoryPoint(key,value);

    §  AddHistoryPoint(key,value,“Text seen in back button history instead of url”)

    §  Process

    ·         Enable history and add event

    ·         When page event fires store value (index, ect) with AddHistoryPoint() in provided history cache

    ·         Use history event to set page back up with value retrieved from HistoryEventArgs

    o   Example: set a form to display an item from the last selected index

    o   Script Combining

    §  Combine scripts for better performance

    ·         Example showed initial 15sec down to 3

    §  Must tell ScriptManager all libraries and it will combine/compress them in to one server call

    §  Must explicitly tell which scripts to use – even separate AJAX libraries

    ·         ScriptReferenceProfiler

    o   Free webcontrols which will tell you all the libraries a page uses to make the above less painful

    ·         Factoids

    o   Ajax initiative started to address Outlook Web Access (OWA); a good example of a web application

    o   Script Manager is just a way to make sure the page includes the Ajax javascript libraries

    §  Ajax script commands prefixed with $

    ·         $get(“my id”) looks to be handy

    §  Can dynamically add event handlers in javascript using Ajax js library

    ·         $addHandler($get(“dropdownlist1”), “change”, myFunc);

    ·         Cool “must have” tools

    o   Fiddler (www.fiddler2.com)

    §  Shows response time, requests/responses, statistics

    §  Tip: must place a dot in uri for Fiddler to capture localhost

    ·         http://localhost./default.aspx

    o   Firebug – Firefox extension

     

    Visual Studio Tips & Tricks

    ·         Ppt slides: http://code.msdn.microsoft.com/karenliuteched08

    ·         A lot more keyboard shortcuts: http://blogs.msdn.com/karenliu/

    ·         MS and partnered with DevExpress which is offering CodeRush Express for free

    o   Required for a lot of the shortcuts and refactoring shown

    ·         Editing

    o   Tools>Options>Editors>C#>Formatting>Set Other Spacing Options>Ignore Spaces

    o   Keyboard tricks

    §  Ctrl M,O               Toggle collapse all

    §  Ctrl M,M              Expand region

    §  F12                         Go to definition

    §  Shift F12              Final all references

    §  Ctrl Shift F8        Jump up Go to definition stack

    §  Ctrl [ or ]              Jump between brackets

    §  Ctrl Alt = or –      Smart Select

    §  Ctrl .                      See smart tag (Implement a missing function, add using statements)

    §   

    o   Snippets

    §  Lots of boilerplate goodies are there.  Really need to start using them

    ·         Ctor

    §  Lots more smart HTML snippets coming

    ·         Debugging

    o   Step OVER properties (r-click at breakpoint to check option)

    o   Step into Specific – list of all functions down the chain you can jump to step in to

    o   Tools

    §  Tinyget – mini stress test

    §  Adphang – get memory dump of w3wp

    §  Windbg – open dump

    ·         Loadby SOS mscorwks

    o   Need sos.dll for windbg to interpret stack

    ·         Deployment

    o   Web.config transform for release, uat, ect

    o   Powerful web deployment publishing options

    §  Http, ftp, fpse

    §  Msdeploypublish

    ·         New MS protocol for host supporting includes database, iis settings, access control lists (ACL), ect

    ·         Free test account at http://labs.discountasp.net/msdeploy

    ·         Other

    o   www.VisualStudioGallery.com  – IDE extensions gallery

    §  PowerCommands for VS08

    o   VS2008 SDK application

    §  Samples tab

    ·         Click to open sample straight in VS ready to go

    Silverlight v2 101

    ·         XAML

    o   A subset of WPF

    o   Read-only designer view

    §  Must edit  XAML by hand

    §  Proper designer on the way

    o   Can at least drag XAML text templates for many controls

    ·         Silverlight Controls

    o   Greatly extended in Silverlight v2

    §  Visit: www.silverlight.net for a demo

    §  Most of what you’d expect in ASP.NET is available in Silverlight

    o   Of Note

    §  StackPanel

    ·         Previously on Canvas available requiring static x,y position designation

    ·         Operates like a panel with z-order

    ·         Security

    o   Lives in a sandbox which can’t be extended for security reasons

    o   There are ways to safe access local (isolated) storage, have a file dialog, sockets, cross domain access

    ·         Nifty

    o   Can easily stream media content with one line of XAML

    o   Can easily spin any element

    Parallelism

    ·         Introduction

    o   Sequential performance has plateaued

    o   When we have 30 cores this may lead to dumber cores where we have a situation that today’s software runs slower on tomorrow’s hardware

    o   Need  to start thinking about parallelism

    §  Understand goals vs. usage

    §  Measure existing performance.  VS2010 has tools to do this

    §  Tuning Performance

    ·         Typically we start with sequential programming and add parallelism later

    ·         VS2010 has Profiler tool for tuning performance

    §  Identify opportunities for parallelism

    §  Use realistic datasets from the outset; not only on site with the customer

    §  Parallelize only when necessary, but PLAN for it as it does introduce race conditions, non-determinism, timing issues, and a slew of other potential bugs

    §  Once code is written for parallelism it can scale to any size automatically without any code changes

    ·         New technologies to help

    o   Parallel API

    §  Task

    ·         Like a thread but more optimal with a richer API

    o   Has a value for threads which must return a value

    §  Accessing the value automatically the same as Thread.Join or Task.Wait

    §  ThreadPool

    ·         Just pass a delegate and let Microsoft worry about the hardware and how to best allocate and spawn threads

    ·         The ideal number of threads = number of cores

    §  TimingBlock class makes it easy to test performance

    ·         No more: (end time – start time) / 1000

    §  Decorate code w/ measurement blocks which appear in Profiler

    o   Parallel Extensions

    §  First class citizen in VS2010 (SDK today?)

    §  Parallel.For and Parallel.ForEach

    ·         Still need to use critical sections around shared resources inside loop

    ·         Tip: Best practice is to parallelize the outer for loop only

    ·         Automatically adds measurement blocks to profiler to see results

    §  Parallel.Invoke

    §  Parallel extended IEnumerable to perform queries much faster

    ·         var q = from n in arr.AsParallel() where IsPrime(n) select n;

    §  Task group

    ·         i.e.  For a quick sort instead of using a recursive algorithm use task groups to leverage parallelism with little change to code

    o   Debugging – Parallel Stacks

    §  Richer API to display tasks or threads and view a holistic mapping of their execution

    o   Tools

    §  Performance Wizard

    ·         CPU sampling, timing, ect

    §  Profiler

    ·         Thread Blocking Analysis

    o   Shows each thread’s parallel execution revealing race conditions affecting performance

    §  Displays information about critical sections in tooltip

    §  Can show dependencies for resources/locks across threads

    jQuery

    ·         Ships in future VS but available now

    ·         Will not be changed by Microsoft but will be supported so we can use it with customers requiring support

    ·         VS intellisense available from jquery.com

    ·         Selectors

    1.       $(“:text”)             tag          Select all text boxes

    2.       $(.required)       class      Select any element with this class tag

    3.       $(“#name”)        id            Select with this ID

    ·         Animations

    1.       $(…).Show()

    2.       $(…).Hide()

    3.       $(…).slideDown()

    4.       $(…).slideUp()

    5.       $(…).fadeIn()

    6.       $(…).fadeOut

    7.       Massive open source libraries with hundreds more

    §  Plugins.jquery.com

    MVC 101

    ·         MVC

    o   Controller (input) pushes to model and view

    o   View (UI)

    o   Model (logic)

    ·         An alternative, not replacement, to traditional web forms

    ·         Easier to test

    o   No dependencies on request/response or viewstate as this everything is explicit and therefore testable

    ·         No server side controls (or designer support), postbacks, or events.

    o   Think back to classic ASP

    o   What is all this by-hand crap?  XAML (WPF and Silverlight) is only notepad as well

    ·         Action, instead of event, fires not in View but in the Controller. 

    o   The View, aka aspx page, has no code behind.

    ·         In Controller can define a action and use wizard to create it’s view (web page)

    ·         ViewUserControl is a collection of html and inline asp which is reusable

    IIS v7

    ·         Modules

    o   ASP.NET managed HttpModules can be plugged in directly to IIS v7

    §  No more unmanaged ISAPI filters

    o   Modules can be managed within IIS v7 Manager

    o   Configuration for modules can be exposed through manager

    §  Customer WinForm configuration can also be exposed

    ·         Config

    o   No more meta-base

    §  All settings exists in central applicationHost.config – similar to a web.config

    ·         C:\windows\system32\inetsrv\config\schema

    §  Can share IIS config for farm scenario

    o   www.iis.net contains a configuration pack which allows you to show the config file within the IIS manager

    Security

    ·         Concept of Security Development Lifecycle (SDL)

    ·         Threat Modelling – package available for formalized  security reviews

    o   Talks about prioritizing risks

    ·         Multi-Pass Review Model

    o   1 – Run fuzz and code analysis tools

    o   2 – Look for ‘patterns’ in riskier code

    o   3 – Deep review of riskiest code

    ·         Golden rule: What does the bad guy control?

    o   What if he controls x & j (resources obtained from user, port, pipeline, compromised file system or database)

    §  Char [] f = new char[3];

    §  f[3] = 0;                                 bug

    §  f[x] = 0;                                 can write a null to anywhere in memory

    §  f[x] = y;                                 can write anything anywhere in memory

    ·         Accepted encryption

    o   AES and SHAXXX only

    o   Everything else is banned!  So long TripleDES

    ·         Do not use:  try { } catch (Exception ex) { }

    o   Hides bugs and security flaws

    o   Catch only exceptions we can handle

    IE v8

    ·         Debug tools included out of the box

    o   Hit F12

    §  Debug javascript

    §  Solve style issues

    ·         Compatibility – new rendering engine following widely-accepted standard

    o   Get prepared for our apps look and feel to break

    o   www.msdn.com/iecompat

    o   Set meta-tag to tell IE8 to continue to render using v7 engine

    ·         Accelerators

    o   Can develop own accelerators which can highlight a name and pass to a website as a parameter.  Employee staff directory, for example.

    Cool Stuff

    ·         Ctrl-,

    o   Quick search feature in 2010

    ·         Ctrl-.

    o   Refactoring: infers using statement.  Generate a new method as your developing

    ·         Web.config

    o   Release version compiles debug/standard web.config and turns off debug, hardens security, replaces config and connection strings

    o   Part of the installer

    Other Stuff

    ·         Ribbon support in VS2008 Feature Pack

    ·         Vista Bridge

    o   Wrapper to get access to Vista controls and features

    o   TaskDialog and CommandLinks

    §  Standard now so will be seen in Win v7

    §  Backwards compatible, just extra messages to standard native button

    o   Restart/Recovery API

    §  Get notified of a reboot

    §  Register delegate called in separate thread when app crashes/reboots

    §  OS will run app with a command line argument you catch to load saved info

    o   Power Management

    §  Get notified about all power related info, low battery, ect

    Biz Stuff

    ·         StepUp Program

    o   Allows customers to upgrade current SKU

    §  i.e. VS Pro to Team Foundation Server

    §  30% discount until June 2009

    SQL Database Publishing to ISPs June 14, 2007

    Posted by codinglifestyle in ASP.NET, C#, Visual Studio 2010.
    Tags: , , , ,
    add a comment

    I’m shocked and appalled I forgot to post this until now.  Recently I put my personal website online and had several SQL tables to import.  Like most ISPs, mine had a query analyzer sufficient for creating tables.  Now, if only I could generate the INSERT statements for my existing data.  Enter the SQL Database Publishing Wizard.  After some googling I found ScottGu’s blog which detailed exactly what I was looking for.

     

    This nice add-on hooks in to the Server Explorer in Visual Studio and allows you to export your DB, or selected tables, as a .SQL file.  You can open this in notepad and cut and paste it in the query analyzer to import both tables and data.

    Fantastic?  Not quite.  My ISP strikes again!  It seems the line feeds within varchar columns were lost when importing this way.  Maybe you’ll have better luck but I had to persevere.  So now I had the SQL file but the ISP’s import functionality was letting me down.  I know!  Let’s write our own!

    I spent so long trying to figure out how to make the ISP do my bidding I almost forgot I was a programmer and it’s fairly trivial to write our own import function.  I swiped most of the code from CodePlex who are working hard to make it easier for us to get our SQL data to our ISPs.  My only change was to use a proper ASPX page with a codebehind.  I used a FileUpload control in conjunction with a Button to import:

        protected void _ButtonImport_Click(object sender, EventArgs e)

        {

            SqlConnection conn = null;                  

            try

            {

                using (StreamReader sr = new StreamReader(_FileUpload.FileContent))

                {

                    // Create new connection to database

                    conn = new SqlConnection(CONNECTIONSTRING);              

                    conn.Open();

     

                    while (!sr.EndOfStream)

                    {

                        StringBuilder sb = new StringBuilder();

                        SqlCommand cmd = conn.CreateCommand();

                       

                        while (!sr.EndOfStream)

                        {

                            string s = sr.ReadLine();

                            if (s != null && s.ToUpper().Trim().Equals(“GO”))

                            {

                                break;

                            }

                           

                            sb.AppendLine(s);

                        }

     

                        // Execute T-SQL against the target database

                        cmd.CommandText = sb.ToString();

                        cmd.ExecuteNonQuery();

                    }

                }

            }

            catch (Exception ex)

            {

                //do something

            }

            finally

            {

                // Close out the connection

                if (conn != null)

                {

                    conn.Close();

                    conn.Dispose();

                }

            }                      

        }

     

    The code will read your SQL file and build up SqlCommands to execute.  Simple!  The only caveat is to use forms authentication or some method of protecting access to this page.  Deleting it when you’re done also works.  So at long last, an import function.  Next time, an export function to keep a copy of my data safe and sound in my own DB.

    http://www.codeplex.com/sqlhost