Andrej Tozon's blog

In the Attic


VS "Orcas": LoginService

ASP.NET 2.0 introduced Membership, Role and Profile providers for storing, validating and managing users' credentials and profiles to the web application development world. While these providers can quite easily be used in the same manner in a desktop application having the database store in the same domain, there is still a significant amount of code you have to write to make your application perform user credentials validation through a remote server (using, let's say, web services).

VS "Orcas" (or more precisely - .NET framework 3.5) brings us Client Application Services, which build up on existing functionality to allow us use these very same features (and more) in our desktop clients, and all communication between client and server would be provided by Windows Communication Foundation (WCF). There's a whole new assembly, dedicated to client services, called System.Web.Extensions, which we'll need when building our sample application. This sample will consist of a simple Login service, residing on a remote server and accessing it's local membership database, and a desktop client, connecting to this service through WCF.

Let's open Visual Studio "Orcas" and begin a new Web Site | WCF Service, called ClientService:

We're going to start with a Login service, which we're going to call whenever user attempts to log in our desktop client. First, we'll remove autogenerated App_Code\Service1.cs file from the project, rename Service1.svc to LoginService.cvs and add System.Web.Extensions.dll to this project's references [you'll find this dll in the c:\Windows\Microsoft.NET\Framework\v3.5.20209\ folder].

Next, edit LoginService.cvs file to make service reference a built-in LoginService class:

<%@ ServiceHost Language=C# Debug="true" Service="System.Web.ApplicationServices.LoginService" %>

We'll also edit your web.config to describe our service and enable ASP.NET compatibility:

<?xml version="1.0"?>
<configuration xmlns="">
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <service name="System.Web.ApplicationServices.LoginService" 
behaviorConfiguration="LoginServiceBehavior"> <endpoint binding="basicHttpBinding" bindingConfiguration=""
contract="System.Web.ApplicationServices.LoginService"/> <endpoint address="MEX" binding="mexHttpBinding"
bindingConfiguration="" name="MEX" bindingName="MEX"
contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="LoginServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <system.web> <authentication mode="Forms" /> <compilation debug="true"> <assemblies> <add assembly="System.Core, Version=, Culture=neutral,
/> <add assembly="System.Web.Extensions, Version=,
Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"
/> </assemblies> </compilation> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider,System, Version=,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
> </compiler> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.VisualBasic.VBCodeProvider, System,
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"

compilerOptions="/optioninfer+"> </compiler> </compilers> </system.codedom> </configuration>

[just a quick note here: using wsHttpBinding instead of basicHttpBinding would make your WCF channel more secure]

The Login service is now complete, we're ready create our user/Membership database. Choose Website | ASP.NET configuration from the menu to invoke ASP.Net Web Application Administration tool, the same we're used to from building ASP.NET web sites in VS2005:

Click Security and wait a few seconds for membership database file to be created in your web project's App_Data folder. Then switch authentication type from Windows to Forms authentication and create a user or two:

OK, we're done with the server part; we're continuing with a simple test client...

We'll Add a new Windows Forms project to the solution, setting it as the StartUp project and reference our Login Service [Project | Add Service Reference]; in the "Add Service Reference" dialog, clicking on Find button will make our LoginService appear in the list of services:

After confirming service selection, a proxy class will be generated and we can start using our service.

To keep this sample simple, we'll use a simple form button to check our user's credentials, and here's the code:  

LoginServiceClient client = new LoginServiceClient();
if (client.ValidateUser("andrej", "p@ssw0rd", string.Empty))
if (client.Login("andrej", "p@ssw0rd", string.Empty, true))
    MessageBox.Show("Login successful");
if (client.IsLoggedIn())
    MessageBox.Show("Logged in");

We're making three consecutive calls to our LoginService. With the first call, we're just validating users credentials. The second call tries to log in the application and the third call checks if the user is logged in. Note that when using persisting logins you'll have to allow cookies on your client side by modifying a part of your app.config:

binding name="LoginServiceEndPoint"

We've just set up a simple remote Login service, which allows our desktop client to use the same membership database we could already be using in our web applications. Coming up next: building up a login form, membership and role providers...

Smarter Client Development with Visual Studio &quot;Orcas&quot;

This series of posts will follow my exploration in forthcoming Visual Studio "Orcas" features, focusing on developing Smart(er) Clients, or, as the above title permits, smarter developing of (desktop) clients. I'll begin the series with my "Orcas" installation experience.

As mentioned, you can try out VS "Orcas" by mounting a Virtual PC image or by a separate installation. Choosing VPC, you get Windows 2003, together with VS2005, SQL2005 and VS 9.0 ("Orcas") already installed. On the other hand, separate installer will install "Orcas" bits only. But before you do that, just make sure you don't have any previous "Orcas" CTPs installed on your PC or you'll get some weird installer errors, complaining on some files being missing from your temp folder. To help you with uninstalling unwanted CTP leftovers, see this page; in my case, I had to manually delete the "Program Files\Microsoft Visual Studio 9.0" folder for a successful install.

To continue, there are some quite serious issues involved with the product installation, some of which are closely related to side-by-side installation with VS2005 and/or SQL2005 (see numbers I./7., II./19. and II./20. in Visual Studio Code Name "Orcas" Release Notes). Although the same release notes suggest using the March CTP from a VPC image, this doesn't seem to fix it, because both VS2005 and SQL2005 are co-installed with "Orcas", therefore suffering from this same issue. It looks like what we really need is a fresh, VS2005-less machine...

One of my next steps will include setting up a separate Windows Vista VPC with clean "Orcas" installation and see how it goes from there. But before that, we'll going to look into some new client features "Orcas" has in store for us... Stay tuned!

&quot;Orcas&quot; March CTP Earlybird

It could have easily been called February CTP, but nevertheless, this CTP probably includes all major features, which will be available in the final Visual Studio 2007 "Orcas". Extensive [and somewhat impressive; WPF designer included] feature list is available on download pages:

I'm going to try and go with VPC image this time, just to see how this newly released [and free] VPC2007 handles it. BTW: VPC2007 finally supports mounting ISO images, larger than 2GB, and, what's also important, supports Windows Vista as host and guest OS. MS also dropped the support for some earlier Windows versions and MS DOS 6.22, but those should remain compatible and still runnable under VPC2007.

Adobe Acrobat 8 on Vista

Looks like quite a few "big" applications still have issues with Windows Vista OS. "Problems Reports and Solutions" Vista feature just notified me today about Adobe Acrobate Reader constant crashing, and reported that there's a new Reader version available, which "might address these problems". Following the provided link, I downloaded latest version of Acrobate Reader (8.0.0 for Windows Vista) and tried to run it. Here's what I got after initial setup files got unpacked:

Before investigating if this happened due to incorrect UAC setting or other security issue, I simply navigated to the folder where setup files were unpacked to [C:\Users\<User>\AppData\LocalLow\Netopsystems\temp\Adobe Reader 8.0\] and simply copied all the files to a new folder on the c:\ root. After running Setup.exe from there, Acrobat Reader installed correctly. Problem solved.

It's probably too early to really complain about issues like this, since Vista is still quite fresh, and this may only be an installer issue, but they certainly don't make it easy for users wanting to adopt Windows Vista right now.

ZX Spectrum WPF screensaver

If you're an old ZX Spectrum freak, there's a project going on a CodePlex site, which might be worth checking out. While browsing through CodePlex projects recently, I bumped upon SpecNix ZX Spectrum emulator. This emulator currently plays back recorded RZX files, and the UI part was made with WPF. The current version was designed as a screensaver [you can watch games playing back when you leave your computer idle], but it also works as a standalone app. Cool!

There's another ZX Spectrum emulator project on CodePlex [called zx360], made with Microsoft XNA and mainly targeting Xbox 360 - maybe that's why I haven't had much success running it on my PC [none of my keyboard keys worked].

MessengerQuote WLW Plugin

I've released an update to my MessengerQuote Windows Live Writer plugin. The plugin should now work with non-English Windows, getting that "My Received Files" folder right this time [see the comments in the original post].

I'd like to thank Scott for offering and providing valuable help with this issue.
[Update: additional thanks go to Stephan for testing on German Windows XP.]

On a side note: another Live product, Windows Live Messenger [8.1] has been released a couple of days ago.

NX7010 SD Card Reader under Vista

Starting with my new life role, I finally found some use for the SD Card reader on my HP NX7010 notebook. Digital baby photos can take up a lot of memory space and soon you find yourself copying them everywhere... one of those locations being my Garmin nuvi 660, the little Car GPS Navigator thingy. Since it can be expanded by SD memory cards, the same kind that can be fed to the NX7010, I thought - why not - and bought a 1G card.

But... somewhere on the road installing Windows Vista versions on the notebook, I lost my SD Card Reader due to a missing Vista driver that wasn't installed in the process. Now, how to get it back? XP drivers usually work, but what happens if you don't have your CD anywhere at your hand's reach? Internet, of course... Well, yes... It turned out that NX7010 SD Card reader XP driver wasn't listed on the NX7010 driver list... Digging all around HP's web site I found one on the NX7000 list, and it worked...

In short - if you're trying to enable SD card reader on NX7010 after upgrading to Windows Vista, here's the place to look: Winbond SD Card Reader Software

On a side note: Microsoft released ASP.NET AJAX v1.0 - get it here!

A new life...

You know that wonderful feeling which hits you when you sign off your successfully finished project? Remember the joy when you finished high school? How about the happiness you felt when you got your first job? Warmth and strong beating of your heart when you first kissed your girlfriend? Combine all this together and it wouldn't come close to the experience of being present at birth of your child as the father.

On this Friday morning, 2007-01-19, a princess was born and a new life, a new fairy tale, begins...

To serve some data facts, I decided on going with C# and making this post a little bit more technical:

Baby Amber = new Girl(3900g, 53cm);

P.S.: Amber and Sandra are doing great and are coming home tomorrow.

This Friday's Links

Again, some Friday links for near future reference:

Windows Live Writer Plugin: Messenger Quote

You like to chat with your friends through Windows Live Messenger? Want to share your stories with the rest of the world? :) Yes, I thought you'd say no... But in case you do want to share and you're using Windows Live Writer to write your blog posts, here's a plugin for you:

Messenger Quote WLW Plugin will let you choose a few lines from your WLM messages' history and insert them into your blog post:

First, select the history file from the top combo box - the conversation sessions will be displayed in the list. Select a few lines and click OK - the quote will be inserted in the following table format [font size was additionally reduced by me]:

28.12.2006 10:32 Andrej Encarta® Instant Answers what's the time?
28.12.2006 10:32 Encarta® Instant Answers Andrej The time in Ljubljana, Slovenia is Thursday, December 28th, 2006 10:32:09 am.
28.12.2006 10:32 Andrej Encarta® Instant Answers thanks
28.12.2006 10:32 Encarta® Instant Answers Andrej You're welcome.

For more formatting options check the "Use friendly format" box and select the template you want format your messages with. You can use formatting parameters, enclosed in braces: {0} stands for Date, {1} for time, {2} is From, {3} is To, and {4} is for the Message. You can select one of the predefined templates or write your own.
Uncheck the "Use color" box to prevent text coloring.

Here's the same text, formatted with the default template [italic text was additionally formatted by me]:

Andrej said: what's the time?
Encarta® Instant Answers said: The time in Ljubljana, Slovenia is Thursday, December 28th, 2006 10:32:09 am.
Andrej said: thanks
Encarta® Instant Answers said: You're welcome.

Feel free to download [zip file contains .dll only] and use this plugin freely. Note: this is the first release, which will eventually be updated with a few enhancements and fixes. I'll be releasing the full source code as a part of the Windows Live Writer Plugins project at CodePlex.

To install, just copy the dll to your \Windows Live Writer\Plugins\ folder. 

You can leave a comment here to share your experience with this plugin...