• ScottGu just announced that VS 2010 RC is ready to download for MSDN Subscribers. Non-subscribers can dowload starting from 10.Feb.2010.

    Visit Scott’s blog or the MSDN Site.

    Tags:

  • Windows 10.02.2010 No Comments

    If your Internet Explorer 8 seem to not do anything, go anywhere, then this may help:

    Go to your Tools >> Internet Options and select the tab Connections. From there click on LAN Settings button and check option Automatically Detect Settings. Uncheck the proxy one if checked.

    Restart Internet Explorer.

    Tags:

  • Use of ASP.NET Membership services with WCF RIA Silverlight Business Application Visual Studio 2008 Template is simplified a lot.

    To be able to use the codebase in this article you will need the following:

    - Visual Studio 2008 SP1

    - WCF RIA Services Beta for Visual Studio 2008 SP1

    After you download and install the above components, when you create a new project in Visual studio, under Silverlight, you will see the new Silverlight Business Application option. Once you create a new project, you will be presented with familiar (if you looked at Silverlight Business Application for July 2009 RIA Services template) yet no-so-familiar (because there are some differences) view.

    When you look at the web.config, you see that there are no providers etc defined for Membership services. But if you are like me, and do not want to use “out-of-the-box” solution with SQL Server Express or you already have a database with the membership services objects, then continue reading.

    First thing is first, we create a connection string to our database, and then add the following to web.config in order to define our providers: (So I can locate this easily later, I added it just under <System.web>)

     <roleManager enabled="true"
    defaultProvider="MyRoleProvider">
    <providers>
    <clear/>
    <add name="MyRoleProvider"
    type="System.Web.Security.SqlRoleProvider,
    System.Web, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a"
    connectionStringName="SqlServer"
    applicationName ="/"
    />
    </providers>
    </roleManager>
    <globalization culture="auto"/>
    <membership defaultProvider="MyMembershipProvider"
    userIsOnlineTimeWindow="15">
    <providers>
    <clear/>
    <add name="MyMembershipProvider"
    type="System.Web.Security.SqlMembershipProvider,
    System.Web, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a"
    
    connectionStringName="SqlServer"
    enablePasswordRetrieval="false"
    enablePasswordReset="true"
    requiresUniqueEmail="false"
    passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5"
    minRequiredPasswordLength="7"
    minRequiredNonalphanumericCharacters="1"
    passwordAttemptWindow="10"
    passwordStrengthRegularExpression=""
    requiresQuestionAndAnswer="false"
    applicationName ="/"
    />
    
    </providers>
    </membership>
    

    Since I am only going to have one application in this solution, I left the applicationName at the default value. Anyway, this is pretty much basic stuff for the membership services.

    Now, if you go and create some roles and users with the ASP.NET Configuration tool (under Tools menu when you have the Web project selected), you will see that your roles and users are created in the database that you defined in your connection string. So, all is good so far.

    But when you try to run the Silverlight App, and try to login, you will get an error message like;
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.

    OK, SQL Server not being found? But I just confirmed that I can “find” the SQL Server through the configuration tool.

    Well, it turns out that the problem was in the User class. This class is in your web project (aka server project) in Models folder. The User class is created by default inside your Authentication Domain service, and it includes a new data member called FriendlyName.

     public partial class User : UserBase
    {
    //// NOTE: Profile properties can be added for use in Silverlight application.
    //// To enable profiles, edit the appropriate section of web.config file.
    ////
    //// [DataMember]
    //// public string MyProfileProperty { get; set; }
    
    [DataMember]
    public string FriendlyName { get; set; }
    }
    

    The underlying AuthenticationBase  call to GetAuthenticatedUser calls GetProfile which is looking for the data member FriendlyName.  it is trying to retrieve this from the database. Since, I just created a new database, I only have the default membership objects and they do no include the FriendlyName.

    So I just comment out this section for now.

    Note : You can avoid all this getting rid of FullName stuff by just adding this (FullName) as a property in the web.config if you wish to do so. Since that is obvious, I wanted to show this way.

    
    //[DataMember]
    //public string FriendlyName { get; set; }
    

    And I also, need to change the following code as well, as it will give you a compilation error. This is user.shared.cs, and can be found in Models\Shared folder.

     public partial class User
    {
    /// <summary>
    ///     Returns the user display name, which by default is its Friendly Name,
    ///     and if that is not set, its User Name
    /// </summary>
    #if !SILVERLIGHT
    [System.Web.Ria.ApplicationServices.ProfileUsage(IsExcluded = true)]
    #endif
    public string DisplayName
    {
    get
    {
    if (!string.IsNullOrEmpty(this.UserName))
    {
    return this.FriendlyName;
    }
    else
    {
    return this.Name;
    }
    }
    }
    }
    

    My, System.Web.Ria object, had the following properties available to me:

    IsInRole (string)
    userBase()
    IsAuthenticated
    Name
    Roles

    So I just return Name:

    
    public partial class User
    {
    /// <summary>
    ///     Returns the user display name, which by default is its Friendly Name,
    ///     and if that is not set, its User Name
    /// </summary>
    #if !SILVERLIGHT
    [System.Web.Ria.ApplicationServices.ProfileUsage(IsExcluded = true)]
    #endif
    public string DisplayName
    {
    get
    {
    return this.Name;
    //if (!string.IsNullOrEmpty(this.UserName))
    //{
    //    return this.FriendlyName;
    //}
    //else
    //{
    //    return this.Name;
    //}
    }
    }
    }
    

    And then you will see that you can login and logout using your own providers.

    Of course, the solution here is only one way of getting this done. You may want to include FriendlyName, or extend the profile. We’ll build on this and do exactly that in the next installment on our look at the membership services with the Silverlight Business Applications.

    Tags:

  • After bypassing January, for reading up on Silverlight, we continue.

    If you create a new Silverlight Business Application from Visual Studio template (I used WCF, not RIA Services – new name means the latest build), and you want to use the Asp.net Membership, then one of the first things you do is adding a connection string and editing your membership provider to use that connection string.

    So you think all is good and then go to Project Menu in VS 2008 and click on the ASP.NET Configuration menu option. Then you are in the familiar web site, and you want to create couple of roles and couple of users. So you check the provider and you see the message that there are no providers selected. You select the advanced link to create a different provider for site functions and you see your Membership provider and test it and all looks good.

    Then you head over to Security to create some roles and you see the following error message:

    An error was encountered. Please return to the previous page and try again.

    The following message may help in diagnosing the problem: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_roles_manageallroles_aspx.BindGrid() at ASP.security_roles_manageallroles_aspx.Page_Load() at System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    And you go, huh…
    Well, solution is easier than you think.If you look at your web.config, you’ll see that there’s a one liner sittin there silently (but causing all kinds of problems for you in this case) :

    
    <roleManager enabled="true"/>
    

    change this to:

    
    <roleManager enabled="true"
    defaultProvider="MyRoleProvider">
    <providers>
    <clear/>
    <add name="MyRoleProvider"
    type="System.Web.Security.SqlRoleProvider,
    System.Web, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a"
    connectionStringName="MySqlServer"
    applicationName ="/myapp"
    />
    </providers>
    </roleManager>
    

    and then you can create users and roles. It’s just that the role Management system needs a provider as well.

    Next, we’ll look at using membership services with Silverlight.

    Tags: , ,

  • Windows 17.12.2009 No Comments

    This email came to my inbox and I wanted to share it with you. I love the idea. Good on you Microsoft.

    Alright … so … you asked for it, we listened and now it’s here!
    Many of you will be pleased to find out that we have announced the availability of a limited pilot of Windows 7 Family Pack in Australia. At launch I asked you to ‘watch this space’ … and now, following your feedback we are pleased to make this offer available in time for Christmas.

    Family Pack entitles you to three licenses of Windows 7 Home Premium Upgrade, in either 32-bit or 64-bit, all for the tidy price of $249 AU (RRP), while stocks last. So now it’s easier than ever to upgrade the family to Windows 7 – and even easier to connect your PCs, notebooks, netbooks and kids PC’s, in the same visually-rich environment that makes everyday use simpler and more engaging.

    With Windows 7 Home Premium, you’ll experience everything from awesome entertainment capabilities through to easier home networking with HomeGroup which allows you to share your favourite photos, videos and music with other networked Windows 7 PCs. Windows 7 has many great new features including advanced window navigation and personalisation with several new improvements to Microsoft Aero® desktop, as well as Remote Media Streaming and improved options for different media formats.

    And what are we doing for the folk who already bought three upgrade licenses to Windows 7 Home Premium prior to 30 November? For those of you who purchased 3 licences at once, we have a limited offer of three complimentary Wireless Comfort Desktops, each featuring a wireless keyboard and mouse set. These keyboards and mice are designed by us, and are optimised for use with Windows 7 – in fact I use one of these every day. To find out if you qualify, contact Microsoft Customer Service on 13 20 58.

    Please note that to you’ll need to provide proof of purchase to qualify for the three complimentary Wireless Comfort Desktops. Acceptable proof of purchase will be a single receipt showing the purchase of three Windows 7 Home Premium Upgrade licenses in a single transaction or up to three receipts showing the purchase of separate Windows 7 Home Premium Upgrade licenses that were purchased by the same person. Receipts must be dated prior to November 30, 2009. Further terms and conditions apply – contact Microsoft Customer Service on 13 20 58 for details.

    Windows 7 Home Premium Upgrade Family Pack will only be available at the following participating Australian retailers, while stocks last: Betta Electrical, Bing Lee, David Jones, Dick Smith, Harvey Norman, JB Hi Fi, Myer, Officeworks, Retravision, The Good Guys, WOW Sight and Sound.


    Tags:

  • Another WTF moment for me.

    Turns out that, this was so buggy, that the VS team has decided to make it disabled, so they can concentrate on VS 2010, where there is a full designer support for xaml. But no preview is pretty bad and on top of that to confuse you more, there is a View Designer menu when you right click a xaml file. So, what’s going on here?

    Well, you can still see the designer in your VS 2008 – just remember it is buggy: If you go way down on your VS 2008 IDE, you will see that your mouse will turn into an arrow – the same one that tells you that you can resize an object. But be very careful as it pretty easy to miss. When you drag that cursor up, you will see that the xaml preview pane will materialize in front of your eyes. You will need to tell it to reload but that’s a small price to pay.

    Hannes Preishuber has a blog entry about this with screenshots.

    Tags: , ,

  • So, here I am as part of my journey, trying to build a RIA enabled application (a huge series of blogs coming about this – writing them).  Everything seems to be working fine, until I need to add a namespace reference to my xaml file. Then context is as follows:

    xmlns:webApp=”clr-namespace:MySilverlightApp.Web

    Notice how .Web part is in red?  Well, Resharper complaining here that it can not find Web, but not only that,  intellisense does not work either. I say OK, may be I did something wrong. Nope, it does not work again.

    Long story short, after many little projects, other sample projects downloads, I am convinced that my Visual Studio 2008 is somehow corrupt. Repaired everything that has something to do with Silverlight. Then.. I decided to play with it a bit more before I did anything drastic, and viola! It worked.

    So, what has happened?

    You see, Silverlight 3 with RIA Services, has a different approach to code generation than we are used to – well, at least I am.  When you have the RIA Services link defined on your Silverlight application and build/run your app, then there is a folder called Generated_Code with at least one file named: YourApp.Web.g.cs.

    YourApp.Web is the namespace of the ASP.NET web application, “g” stands for generated and “cs” is of course for c sharp. But the kicker is,this folder is not visible. You have to click on the “Show All Files” button right under the Solution Explorer in Visual Studio to see this folder and its contents.

    And of course I knew about this, however since the project works fine without this folder being explicitly included in the project, I assumed that the intellisense etc would work just fine. That was not the case.

    Once the folder is included in the project, intellisense started to work and Resharper was much much much happier.

    So, there it is: If you are trying the RIA Services and somehow the sample projects you download are working fine, but you can not even do a simple;

    
    using MyWebApp.Web;
    

    then you know where to look first. Include that hidden baby in your project, and you will get rid of the red markings and get your intellisense.

    Tags: ,

  • In short, you probably had VS2008 installed + .net RIA Services installed (for VS2008). Apparently, when you are installing VS2010 Beta 2 side by side with VS2008, the installer seeing that there is another RIA Services on the machine, silently fails and keeps going on happily.

    To get the templates in VS2010 Beta 2, you need to uninstall VS2008 RIA Services first and then install the new ones. And that is right, once you go 2010, you can not go back to 2008 :-) So, if you want to continue working with VS 2008 and develop .net RIA services then you need to install VS2010 Beta 2 to another environment or to VM or to VHD.

    More information can be found in Tim Heuer’s blog.

    Tags: , , ,

  • This is just an awesome tool. Check it out by watching this video and then downloading the tool from here.

    And of course, Karl’s blog is something that no Silverlight/WPF developer wants to miss.

    Tags: , ,

  • I started to play with Silverlight only last week but already falling in love with the technology.

    So, I will start a series of blogs/articles/tutorials about my transition to Silverlight (3 for now) and hopefully pick up some friends along the way. in this process, we will build a time tracker app as sample app, however we do not want this to be yet-another-simple-but-useless-intro-to-the-technology kind of application as those are in abundance all over the net.

    For starters, here are couple of excellent articles:

    Understanding Routed Events and Commands In WPF

    WPF Apps With The Model-View-ViewModel Design Pattern

    First, we will cover some areas in Silverlight that will lay the foundation to our knowledge, and we get to know what is what in this new silver world. From there on, we will start building our app and try to tackle the hurdles together. The final application will be somewhat blending of all the blog ideas and articles together.

    Well, let’s begin.