Wednesday, July 18, 2007

South Park yourself

Pretty neat flash game - you can create your own South Park character.

This has pretty close resemblance to one guy I know. Just a little bit too athletic maybe...




Dear lawyers, all legal rights, etc. belong to those South Park guys. I am not responsible for anything. Do not steal or get caught. Flash game results belong to the site owner who knows what she is doing.

If you've ever wanted to watch icebergs but wasn't sure where to go...

Keep an eye on'em and your vacation time never will be wasted!

Monday, July 16, 2007

Decided to solve problem with regular expressions? Now you have two problems...

Regular expressions is real pain for me. Somehow :) I use them so rarely so I have to learn them almost from the very beginning every time I need them. By the moment I know enough to use it successfully I can move on for next few months and my knowledge evaporates till the next stop on this vicious circle.

I used handy online regex tester until recently. It chokes sometimes (certainly not due my poor syntax ;) but it's very good for quick test. Eventually smart people pointed me to a lovely Espresso utility. With the help of this great tool regular expressions are not that excruciating. At version 3.0 it packages a lot of features and is very user friendly. Just go there and get it. For free.

Cool "Apple" commercial

It is environmentalist point of view but in more generic way there is no big difference between corporations Apple and Microsoft. Apple is even more evil.

Learning as I go - comment moderation

I have to apologize - I turned on comment verification and moderation. The comment process will be slightly more tedious and you won't be able to see your comment right away, but please do not feel frustrated, I will love to hear from you but give me few hours (more like 24 :) to publish it.

Friday, July 13, 2007

Setting up multiple web sites on Windows XP

So far Vista is not very impressive. But it has one (among very few :) advantage - it comes with IIS 7, which can hold multiple web sites. There is no need to explain, what convenience it provides for web applications development and debugging. For those who works on Windows XP there is a way to emulate (just emulate, folks!) multiple sites on their IIS. You won't be able to run more than one site at once (common, it's not a server!) but still it's pretty handy - you can screw one up with SSL and another with crazy ISAPI filters absolutely independently. So this is what you can do:

Stop the Default Web Server. Navigate to the admin scripts folder (normally c:\inetpub\adminscripts) and run the following command:

adsutil.vbs enum /p w3svc

If you really want to know how the administration scripts work, check here. This particular command will enumerate your default web site as number 1. The script may fail for the first time and offer to register C# scripting or something like that, so just agree on all prompts and run the same command one more time.

Now you can create a copy of your default web site:

adsutil.vbs copy w3svc/1 w3svc/2

And you have yourself a nice second site. IIS MMC most likely will not reflect new site even after refreshing, so just close and reopen it. You can rename the second site the way you want.
Note: always copy from the default site (w3svc/1) and always keep your default web site untouched for a template.

Again - unfortunately, you can not have two sites running simultaneously. You will have to stop before starting another.

Sunday, July 08, 2007

Visual Studio 2005 Web Application Projects and Windows Vista. Duh!

The problem:

The ASP.NET can not be debugged properly under Vista (Home Premium?) IIS7.

The bitching:

Microsoft rushes too much. Maybe it is all result of the H1B visa situation (US government was bribed by Apple!) which they try to resolve with new Vancouver development center. In this case it better be a new QA center, as they have already enough clumsy developers and not enough QA personnel. And Technical Writing center would be nice to have too. An article which is supposed to help with your Vista-related problems recommends to install "IIS 6 Compatibility Layer" 8 times between 600 lines without a single link to the software or instruction...

The solution:

Read this, this and this to educate yourself or just install this patch (the related article is still not available, of course) and enjoy long missing debugging.

Saturday, July 07, 2007

Generating client code for a WCF service: part II

I mentioned in Part I that svcutil.exe will generate a nice client proxy code for your service. It appeared not so nice at the end and I spent some time trying to figure out the correct contract type description for the client configuration. It ended up to be a very small tweaking - I just brought all types under the single namespace umbrella. This code was generated (some attributes and code lines are removed for simplicity):

namespace WCFServiceNamespace
//WCF Service classes mapping {...}

public interface IServiceContract {...}

public interface IServiceContractChannel
: IServiceContract System.ServiceModel.IClientChannel{}

public partial class WCFServiceClient
: System.ServiceModel.ClientBase<IServiceContract>, IServiceContract {...}

The contract interface IServiceContract here is one of the most important parts - before everything happens, the application should find the contract type to create the instance of the proxy class. As you can see, the interface is outside the namespace. This separation reflects the real order of things but I would prefer convenience. So to avoid confusion, let's bring all types under the client's main namespace ClientNamespace:

namespace ClientNamespace.WCFServiceNamespace
//WCF Service classes mapping {...}

[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "IServiceContract")]
public interface IServiceContract {..}

public interface IServiceContractChannel
: IServiceContract System.ServiceModel.IClientChannel {}

public partial class ProductsServiceClient
: System.ServiceModel.ClientBase<IServiceContract>, IServiceContract {...}

Now the proxy can be created easily with the following endpoint configuration:

<endpoint address="net.pipe://localhost/WCFServicePipe" binding="netNamedPipeBinding"
contract="IServiceContract" name="binding_IServiceContract" />

Monday, July 02, 2007

Generating client code for a WCF service

Sometimes it is good to have a distributable proxy code for a WCF service prior it's been deployed and it is not possible to generate a client proxy through a wizard. There is a nice little utility SVCUTIL.EXE, which comes with WCF. I've seen it located under C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin and Program Files\Microsoft Visual Studio 8\Common7\IDE folders. This utility allows to generate client proxy class and configuration template from a compiled WCF service library or executable.

First run utility against a compiled service code to generate metadata documents:
svcutil.exe MyService.dll.
It will generate a whole bunch of XSD and WSDL files. The next command:
svcutil.exe *.wsdl *.xsd /language:c#
will generate MyService.cs class - strongly-typed client proxy (guaranteed against the weird WCF proxy generation in Win App :), and output.config file - client endpoint and binding configuration.

These tricks are better described in the utility help than on Internet and it took me a while to figure out, so I decided to share it.

© 2008-2013 Michael Goldobin. All rights reserved