Default browser VS2010 Add-in

Ralph JansenLast weekend I was working on a MVC 2 application. When I started the application my default browser (Google Chrome) came up. I actually wanted to change my browser for this application to Internet Explorer because the connectivity between IE and Visual Studio 2010 is much better than with Chrome.

The problem is that you can’t choose for the option “Browse With” in a MVC Application. This is because the controller is deciding which view should start. To fix this problem, I found an add-in for VS2010 that you can switch your default browser on the fly from your toolbar. In that way, you can switch easier between your installed browsers. See the screenshot below. image

You can download the add-in by following the link below.
http://visualstudiogallery.msdn.microsoft.com/en-us/bb424812-f742-41ef-974a-cdac607df921

 

Update:
If you get a popup on the startup of your Visual Studio Instance with the text: “The bits have expired, please download an updated version from http://www.wovs.com”, you have to download the new version. To do this, follow the steps on this website: http://blog.wovs.com/2010/10/how-to-update-currently-expired.html
Search in the online extension manager for “Default browser switcher”.

Master-Detail with Silverlight RIA Services

Ralph Jansen

If you want to have a master detail view of you data in Silverlight with RIA Services you have to do two things. One thing is to tell your RIA Services meta data file that you’re including the related entities and you will have to tell your domain service as well that your including the related entities. Follow the tutorial beneath to accomplish an example for creating a master detail relation with Silverlight RIA Services.

Silverlight application

Create a new Silverlight 4 application in VS2010 and enable RIA Services. Also don’t forget to check the box to host your Silverlight application in a website.

Model

Create your Entity Framework 4.0 model so we can generate some RIA Service over it. Just use a simple example so we can practice the master detail relationships. The example that I use is shown below.

image

RIA Services

After your model is created we have to create the Domain Service that exposes your model from the server to the client. If you haven’t used RIA Services before, I suggested you should read the documentation on the http://www.silverlight.net homepage.

Select add new item on your server website. The same place as you created your Entity Framework model. Now search for the Domain Service template. After you clicked the OK button, you will get a popup that is asking you to specify which entity the domain service should expose from your Entity Framework model. Click the Brands and Product collections, select the checkbox to generate meta data files and to enable client access.

Your Domain Service would look something like this:
image

Creating the UI

Open your MainPage.xaml file that is generated by creating the Silverlight Application. Open your Data Sources window in VS2010 and drag the Brands and Products grids to your MainPage. You have to drag your Products from the inner collection of Brands.

image

Now if you run your code. Only the brands will be shown because the UI is connected to the GetBrandsQuery. Now we want to include the products to create a Master Detail relation.

Configure the Meta data

Open your meta data file that is generated by the Domain Service. Find your Brands Entity and in that entity the inner collection property of Products. Add the [Include] attribute above the inner collection of products. In that way we tell RIA Services to include the products for the brand if the products are available.

image

Make the products available

To make the products available for RIA Services you should include them in the correct query that is used in the client. In our case it is the GetBrands in the Domain Service class.

image

Add the include statement like below to the query.

image

Now you are ready to run your code and see a nice example of a master detail relationship in the client.

Note:

It is better to create a new query then change the default query. In that way the performance is better because you don’t need the products every time you use the GetBrands query. You can create a query like GetBrandsWithProducts. If you do this, don’t forget to change the query name in the client. This is still referenced to the GetBrands query!!!

ASP .NET MVC 3 Release Candidate released

Ralph JansenOn November 9th 2010 the ASP .NET team released the release candidate of MVC 3. The big change of MVC 3 is the new “Razor” view engine. With this new view engine the syntax of the code is a lot smaller. You now just put an @ on your editor and the intellisense will pick it up.

An other thing that is added in MVC 3 is: partial caching of pages. You can add an attribute above your action in the controller with the right amount of seconds that you want to cache the information. You can even say what the dependent parameter is that the caching will focus on. So if an action is fired and the parametervalue is the same as a previous parametervalue within the specified amount of time, the data will come out of the cache. That way, no database call is required!!!

Check for more information the blog of Scott Guthrie or the official ASP .NET MVC 3 Releas Candidate page.

Change Class template in Visual Studio 2010

Ralph JansenIf you want to change the default ItemTemplate of a class file in Visual Studio 2010, you can follow the steps below.

  1. Go to the right folder on your local machine.
    1. x64: C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEItemTemplatesCSharpCode1033
    2. x86: C:Program FilesMicrosoft Visual Studio 10.0Common7IDEItemTemplatesCSharpCode1033
  2. In that folder you will see the Class.zip file. If you open the class file directly from the zip, you can see the default class template of Visual Studio 2010. In my case, I want to add some default stuff like regions and constructors.
  3. Save the class file. It could be that you get a question that the zip file has changed and want to be reloaded. Click in that case “Yes”.
  4. Now, if you open VS2010, you won’t get the new class template yet. This is because the class template is not yet available in VS2010. VS2010 uses an ItemTemplatesCache directory to store the active templates. You need to override the already active template. This sounds very difficult but is very easy to do. Open your Visual Studio command prompt from the visual studio installation folder in your start menu.
    image(You maybe need to open it as Administrator)
    Fill in this comamnd: “devenv.exe /installvstemplates”
    The strange part here is that you won’t get any confirmation about the success of the installation. This could take a while because when I looked several times in visual studio, I still got the old template. After a few minuts, the new template was suddenly there.
Notes:

  • It is better to close all your Visual Studio instances. before you follow these steps above.

  • These steps should also work for Visual Studio 2008 but I haven’t tested it.
    Sample template:

    /*using System;
    using System.Collections.Generic;
    $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
    $endif$using System.Text;

    namespace $rootnamespace$
    {
    public class $safeitemrootname$
    {

    #region Constants

    #endregion

    #region Private Fields

    #endregion

    #region Private Properties

    #endregion

    #region Public Properties

    #endregion

    #region Constructors

    /// <summary>
    /// The default Constructor
    /// </summary>
    public $safeitemrootname$()
    {
    }

    #endregion

    #region Private Methods

    #endregion

    #region Public Methods

    #endregion

    }
    }*/

    Image:

    image

  • How to change the setup.exe icon

    Ralph JansenIf you create an application, you have also create an installer project. The installer creates two files for you. An setup.exe file and a msi file. The icons of the two files are set by the default windows icons. In Windows 7 it looks like this: image

    If you want to change the icon of the installer, you can not do that by default in your installer project. Also, the icon of the msi file can not be changed at all. For the setup.exe file you have to do it manually for each time you create a new installer. So every time you fix a bug and releases a new version of your application by the new created installer you have to set the icon manually. Lucky that this is not hard to do.

    Change the icon

    1. Create an installer project with the right settings that you want and build it.
    2. Now open the setup.exe file in the release folder (that is the one that you want to give to your client) in Visual Studio. You can do this as follow:
      1. Click in Visual Studio on File –> Open –> File
      2. Navigate to the exe in the release folder
      3. Click open and then you will see an explorer in Visual Studio
        image
    3. Right click with your mouse on the icon folder and choose “Add Resource…”
    4. The icon type is now selected by default. Choose on the right of the popup for “Import”
    5. Navigate to the right icon that you want and select it
    6. The popup will now close and the icon folder in the explorer is expanded
    7. Make sure that your new icon has the lowest ID. If you don’t do that, the icon will not been shown
      image
    8. Save the setup.exe and return in Windows Explorer to the release folder. You should now see the new icon.
      image

    How To: Bloggen naar sharepoint én…

    Sorry but this post is only available in dutch.

    Zijn jullie het ook zat dat:

    • Alle lettertypes van elke blog anders zijn
    • Alle letter grotes van elke blog anders zijn
    • Je niet makkelijk een plaatje kan zetten in je blog
    • Je niet makkelijk een plaatje tussen de tekst kan zetten

    Gebruik voor dit probleem de Ralphanizer tool. Deze tool heeft voor alle bovenstaande problemen en meer een oplossing. Door sommige mensen wordt deze tool ook wel Microsoft Windows Live Writer genoemd. Met deze tool kan er worden geconnect naar Sharepoint en alle populaire blogs zoals WordPress.

    Downloaden
    Download Windows Live Writer van www.msn.nl. Windows Live Writer (verder in dit artikel noem ik dit tool) is een onderdeel van de live producten van Microsoft. Je kan het dus vinden op dezelfde plek als het downloaden van MSN Messenger.

    Installatie wizard
    Bij de eerste keer opstarten zal er een wizard worden opgestart. Volg dan onderstaande stappen.

    1. Selecteer bloggen naar sharepoint
    2. Vul bij de volgende stap de volgende url in: Your sharepoint blog page
    3. Nadat de tool is geconfigureerd zal er om een unieke naam worden gevraagd. Bijvoorbeeld “Advanced Solutions Blog”
    4. Klaar

    Extra instellingen
    Ga voor extra instellingen naar het menu. Klik in het menu op Extra en vervolgens op Accounts. Nu zal er een venster worden geopend waar je rechts de configuratienaam van de wizard terug ziet. Als voorbeeld was “Advanced Solutions Blog” gegeven. Selecteer deze en klik op bewerken.

    Vervolgens zullen de details van deze configuratie worden geopend. Selecteer links in het menu weer op bewerken. Druk vervolgens op de knop “”. Hiermee worden de stijls van Sharepoint binnen gehaald. De blog wordt nu meteen in andere kleuren en lettertypes weergegeven.

    Blog opmaken
    Het opmaken van je blog gaat op deze manier snel en gemakkelijk. Voordat je hem upload kan je zelfs onderaan een preview zien van je blog of de bron code opvragen waardoor je deze blog ook kan kopiëren naar andere toepassingen.

    Het toevoegen van hyperlinks, plaatjes, tags, video’s, kaarten (Bing koppeling), fotoalbums, categorieën van blogs of publicatiedata zijn nog nooit zo makkelijk gemaakt. Zodra je het programma download en opent is alles eigenlijk in één oog opslag duidelijk.

    Happy Blogging!!!

    Building a Service Oriented Architecture (SOA)

    Sorry but this post is only available in dutch.

    Afgelopen dinsdag was het zover. Een aantal weken geleden was er een mail verstuurd waarin twee events werden aangekondigd. Deze events zouden gaan over het opzetten van een Service Oriented Architecture (SOA). In deze blog wil ik het hebben over het eerste event die dinsdag 15 december 2009 plaats vond.

    De presentatie werd gegeven door Dennis Doomen. Dennis Doomen is een Software Architect die zich voornamelijk richt op SOA omgevingen. Als eerste werd aangegeven wat het nut was van een SOA omgeving. Het ideale binnen een bedrijf is namelijk dat alle cliënts via dezelfde service laag lopen. Op deze manier praat elke cliënt tegen dezelfde Business Logic aan waardoor het aantal fouten minimaal is. Mocht er iets veranderen in de logica, dan hoeft dit maar op één plek te worden gedaan.

    Voor het aanmaken van een servicelaag werd er gebruik gemaakt van de “webservice software factory” tool. Het voordeel van deze tool is dat er minder hoeft te worden geprogrammeerd. De webservices, de host en de entiteiten kunnen worden gemoduleerd. Nadat alles is gemoduleerd kan alles worden gegenereerd. De tool maakt zelf alle projecten, classes en knoopt alles aan elkaar vast. Vervolgens hoeft alleen de logica te worden geschreven.

    Meer details over het event zijn te vinden in de presentatie. Deel twee van het event zal plaats vinden in het nieuwe jaar. Namelijk op 5 januari 2010 in de avond. In deel 2 van dit event zal er meer inhoudelijk op de onderwerpen worden ingegaan. Daarnaast zullen er voorbeelden worden gegeven over het maken van een SOA.

    Hopelijk zie ik jullie dan ook op het tweede deel van het event. Voor nu een fijne kerst en alvast een gelukkig nieuwjaar!!