in

Dé specialist in .NET trainingen en consultancy

Erik van Appeldoorn

  • Precompile ASP.NET MVC views

    Views in an ASP.NET MVC project will not be compiled by default. Syntax errors made in views will only show up as runtime errors in the browser.

    There is a small hack to include the views in your compile process:

    • Unload your project file (.csproj or .vbproj)
    • Edit this file and look for the line: <MvcBuildViews>false</MvcBuildViews>
    • Change false to … true, indeed you know what you are doing.
    • Save the projectfile and you are good to go.
  • Code productivity tools

    The excellent Visual Studio Toolbox series on Channel 9 published three videos on the most popular code productivity tools for Visual Studio:

    DevExpress CodeRush:
    http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-Studio-Toolbox-DevExpress-CodeRush

    JetBrains ReSharper:
    http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-Studio-Toolbox-JetBrains-ReSharper

    Telerik JustCode:
    http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-Studio-Toolbox-Telerik-JustCode

    Code productivity tools add new refactoring options, code snippets, keyboard short-cuts, navigation windows, renaming functionality etc. to Visual Studio and when used to it it will certainly speed up your coding.

    If you’re new to coding productivity tools you should really check these videos out. If you’re already using one, great but take some time to watch the other videos to see if you’re weapon of choice is still the best weapon for you.

  • Silverlight 5 released

    At 9 December 2012 a new version of MS RIA development platform Silverlight 5 has been released. New features include: GPU accelerated video decoding, 3D graphics, playback speed controls, remote control and 64-bit support.

    To start developing with Silverlight you’ll need Visual Studio 2010 and the Silverlight 5 for Visual Studio 2010 SDK

    To get you started, some helpful resources:

    http://www.silverlight.net/
    http://www.microsoft.com/silverlight/http://blogs.msdn.com/b/silverlight_sdk/archive/2011/12/09/silverlight-5-has-released-the-docs-are-up-and-a-chm-is-available.aspx
    http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2011/12/10/silverlight-5-released.aspx
    http://msdn.microsoft.com/en-us/library/gg986857(VS.95).aspx

    This year Microsoft started MCTS certification for Silverlight, for more info about the Silverlight 4 exam (70-506)
    http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-506

    Oosterkamp has some high quality Silverlight courses available. Next month a 3 day Silverlight 4.0 jumpstart training has been scheduled: http://www.oosterkamp.nl/Training/DetailByName/silverlight4.0 (dutch only).

  • Intellisense not working in SQL Server Management Studio

     

    This week I noticed that SMSS intellisense didn’t work anymore on my machine. After some googling I found out his issue was related to the Visual Studio 2010 SP1 update. It seems SQL Server 2008 R2 and the VS2010 SP1 update don’t like each other too much. Installing the SQL Server 2008 R2 SP1 update solved the problem for me.

    Posted okt 06 2011, 11:15 by Erik with no comments
    Filed under: ,
  • Personal Top 10 Visual Studio 2010 native short-cuts

     

    A personal Top 10. No CodeRush/Resharper involved, just plain old VS short-cuts. If you think your favourite short-cut is missing let me know, it can be worth another post.

    1. F5 / Control-F5  : How does this ‘meisterwerk’ looks like when I run it, absolutely number one.

    2. Control-Shift-B :   Please, please praying it still compiles.

    3. Control-Shift-L :   Delete Line. I like deleting code. The best code is no code.

    4. Control- , : Navigate To dialog. New in VS2010 and very helpful.

    5. Control –. Get that context menu up, so VS can add a using statement automatically.

    6. Control-Space : Intellisense up and running again, when it’s gone.

    7. Control+K, Control+D: Fresh formatting again.

    8. Control+Shift+V: Cycle through the clipboard

    9. Control+Shift+A: Add new item…

    10. ALt-F4: Close Visual Studio and have a cool Belgium Beer.

  • View.ViewCode keyboard mapping in VS2010

    For all keyboard lovers: There is a command available in VS2010 to get the cursor in the editor window: View.ViewCode. I’m using the default scheme in VS2010 and found out by default there is no shortcut key defined for this command. But it is easy to add new shortcut bindings:

    Go to Tool | Options | Environment Keyboard and search for the View.ViewCode command. Select the command and assign a new shortcut key.

    View.ViewCode

    Posted feb 28 2011, 01:29 by Erik with no comments
    Filed under:
  • Entity Framework Code-First

    EF Code-First is a new flavour in the Entity Framework 4.0. Ice Cream Bar. Instead of creating a model (model-first) or reverse engineering a database (database-first) you just start writing code, isn’t that sweet?

    Actually it’s quite simple and straight forward:

    Your entities are pure POCO classes, no need to derive from a base class or implement any interfaces.

    Navigation properties can be defined by using the ICollection<T> interface.

    public class FAQCategory
    {
        public int Id { get; set; }

        public string Description { get; set; }
          
        public virtual ICollection<FAQItem> FAQItems { get; set; }
    }

    A context can be created by deriving from the DbContext class:

    public class CustomContext : DbContext
    {
    public DbSet<FAQCategory> FAQCategories { get; set; }

        public DbSet<FAQItem> FAQItems { get; set; }
    }
     

    In EF Code-First there is no visual model (.edmx), all we have is code

    EF Code-First can create the database for you, or you can map to an existing database.

    Validation is supported by using Data annotation attributes.

    To download EF Code-First (CTP-5) click here. For more details: read Scott Guthrie BLOG

  • Using additional fonts in Silverlight

     

    Today I wanted to use a font other than the default ones for a TextBlock element in a Silverlight 4 application.  To accomplish this using Visual Studio 2010 I had to:

    • Add the font file (.ttf) to the project
    • Set the Build action of this file to resource so it will be included in the assembly
    • Add a reference <font file name>#<font name> for the FontFamily attribute of the TextBlock element.

    For more information about these actions take a look here.

    Although this process is ok, doing the same in Expression Blend 4 is just a breeze.

    • Select the required font using the Properties tab of the TextBlock control
    • Make sure the Embed flag is checked and you are done

    BlendFontSelection

  • Looking for a MVVM framework

    I am looking for a MVVM Framework that could help me implement the MVVM design pattern for a Silverlight 4 application. During a dotned meeting Gill Cleeren showed the MVVM Light Toolkit from Galasoft. It comes with Visual Studio templates, documentation and demo’s.

    I played around with The MVVM Light Toolkit and found it easy to learn, well, at least when you are familiar with the MVVM concepts of course.

    Download: http://mvvmlight.codeplex.com/

    I also downloaded Caliburn.Micro. MVVM in Caliburn is heavily based on naming conventions which makes it maybe even easier to use. It also comes with some advanced concepts like ActionMessages and Coroutines, I didn’t found the time yet to do a deep dive but like the MVVM Light Toolkit it seems Caliburn.Micro can serve me as well.

    Download: http://caliburnmicro.codeplex.com/

    I haven’t decided yet, so mail me (erik@oosterkamp.nl) if, in your humble opinion, I should use one of these or another framework. Looking forward to the reactions.

  • VS2010 web deployment: publishing profiles

    A lot of developers still use external FTP clients or even copy/paste to deploy their ASP.NET or Silverlight web project on the production server. It’s good to know Visual Studio can do this job for you. Just right-click your Web application project in the solution explorer and select the Publish… menu-item.

    Publish… will pre-build your project and copy the necessary files to the destination server in one go. In Visual Studio 2010 it’s now possible to save your publishing options using a profile.

    PublishingWeb

    The profile will be saved as a XML file in the root directory of your web application. The name of the file follows the format [ProjectName].Publish.XML. And no panic, the password will be saved encrypted. If you are still using Visual Studio 2008, you don’t have this profile feature and you’ll have to fill in your credentials manually during each deployment action.

    For more complex deployment scenarios, including database deployment, altering IIS settings etc.. you should take a look into the new webpackage deployment option in VS2010. For more infomation on this subject take a look here.

  • Delphi 2009 resources

    Last week I did a Embarcadero Delphi 2009 course. While preparing this course I came to a number of resources on the web. If you need info about Delphi I would recommend the following sites:

    1. Delphi basics. A language reference guide to the OO Delphi language. http://www.delphibasics.co.uk/

    2. To download a Delphi Quick Reference Card look here: http://www.explainth.at/en/qr/dqr.shtml

    3. New Delphi language features since Delphi 7. http://edn.embarcadero.com/article/34324

    Posted apr 26 2010, 09:06 by Erik with no comments
    Filed under: ,
  • Custom ASP.NET MVC2 Data Annotations

    This afternoon we did some work to update our corporate site to MVC 2. We are using the new System.ComponentModel.DataAnnotations attributes to decorate our domain entities and by doing so you‘ll get some nice validation for free. 

    Introducing your own Data Annotation attribute for MVC2 is just a matter of creating a derived Class from ValidationAttribute and override the IsValid method.  By default this will be a server-side validator. To change that into a client-side validator takes some effort. The main steps are:

    - Create a new validator Class derived from the generic DataAnnotationsModelValidator<--your custom attribute Class goes in here—> Class. 
    - Register the validator and Custom attribute in global.asax.
    - Write a custom JavaScript validation function.

    For all the details I would recommend reading this excellent article about ASP.NET MVC 2 Custom validation.

  • Silverlight 4: WebBrowser control

    The new WebBrowser control in Silverlight 4 is capable of showing HTML content based on a URI or string within your Silverlight application. There are just 2 gotcha’s:

    1. At this moment the WebBrowser control will only work if the application runs in Out of the Browser mode. Like you suspect by the name, in this mode the application doesn’t run in the browser anymore but will run locally like a normal desktop app. You have to enable OOTB mode explicitly in Visual Studio. You’ll find this option in the Silverlight project properties pages.

    2.  During the install the client needs to give the Silverlight application permissions to travel over the web. So there is an extra option you have to set to get this control working. Check the Require elevated trust when running outside the browser option in the Out-of-Browser Settings dialog.

    Silverlight4WebBrowser

  • ASP.Net 4.0 new page attributes found in web.config

    Today I converted an ASP.NET 2.0 webapplication to 4.0 using Visual Studio 2010 RC.  The convert process ran quite smoothly. After the conversion I discovered two new attributes in the pages tag of the converted web.config file, curious?

    1. controlRenderingCompatibilityVersion="3.5"

    Default HTML rendering of web server controls will be according the rendering of the controls in the version 3.5 of the .NET framework.  The minimum value of this attribute is 3.5. More info on MSDN

    2. clientIDMode="AutoID"

    ASP.NET 4.0 gives the power to control how id’s are generated in the rendered HTML of web server controls. And that is a good thing. For compatibility reasons it’s set to AutoID here so it will be the same as always. More info on MSDN

  • Hosting website for Silverlight Application.

    When you create a new Silverlight Application in Visual Studio a dialog box comes up with an option to host the application in an ASP.NET Web Application. When you check this option a ASP.NET Web Application project will be added next to the Silverlight application in your VS solution and the .xap output of the SL is copied automatically for you in the /ClientBin folder of the ASP.NET web application when you build the complete solution. Cool, flex, everything fine.

    DemoSilverlight1

    But…What if you decided to deselect this option and you regret this later on..

    No problem, it’s always possible to add a hosting ASP.NET Web application later on:

    1. Just add a ASP.NET Web Application project to your Solution
    2. Go to the property pages of this application (Right click on project in Solution Explorer | Properties)
    3. Select the Silverlight Applications tab
    4. Off you go.

    DemoSilverlight2

More Posts Next page »