MEF + WCF: Config issues

9 October 2009 Tags  , ,

MahTweets makes extensive use of the Managed Extensibility Framework (MEF) for plugins, and recently we had the need for a plugin to use WCF to connect to an external service. The plugin was going to connect to the Bing Translation Service, and auto-translate all tweets into the language of your choice.

wcfmef

However, we ran into a few problems. The normal WCF magics picks up the configuration automagically from your app.config. WCF looks at the program app.config, but under MEF this gets a little trickier. It continues to look at the host programs app.config not the plugin app.config. Something about AppDomains.

There are a few solutions

1. Write all your configuration in code behind

I haven’t actually figured out how to do this for WCF clients but for hosting WCF services, its fairly easy. Adding yet another plugin, I needed to do some hosting over NetTCP bindings (named pipes). This particular service is so the TweetSaver plugin can work.

ServiceHost service = new ServiceHost(typeof(TweetSaverService),
                      new Uri("net.tcp://localhost:3131/TweetSaverService"));

service.AddServiceEndpoint(typeof(TweetSaverService), new NetTcpBinding(), "TweetSaverService");
var smb = service.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (smb == null)
    smb = new ServiceMetadataBehavior();

smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
service.Description.Behaviors.Add(smb);
service.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
    MetadataExchangeBindings.CreateMexTcpBinding(), 
   "net.tcp://localhost:3131/TweetSaverService/mex");

service.Open();

Obviously for different types of bindings there are differences, but the configuration doesn’t vary too much.

2. Use ye-olde Web Reference instead of Service Reference

In Visual Studio 2008, you can’t just right click on the project to Add Web Reference anymore, it’s hidden away a little.

Right click on your project, Add Service Reference –> Advanced –> Add Web Reference

Or in pictures (click on any image to enlarge it)…

image image

image image

This is the method I ended up using for the Translator plugin, simply because it was the path of least resistance/work. The older style of SOAP interaction still uses configuration files, but unlike WCF it is happy to look in the plugin configuration file.

3. Include the configuration information inside the host config

I’d highly recommend against this, as it really defeats the purpose of having a plugin in the first place, but you can get around the issue by putting the configuration from your plugin’s app.config into the host program’s app.config.


3 Comments
 

Xbox 360/Halo Tournament wrap up

25 September 2009 Tags  , ,

Last Friday (18th) the Deakin MSPs held the first (of hopefully many) annual inter-Uni Xbox 360 Tournament at Deakin Uni (Burwood). 10 teams competed in Halo 3, fighting over 4 x Halo 3 Legendary Edition + Gears of War 2 + Ninja Gaiden 2 + Forza 2 (that was just for first place other games were awarded for the other 3 places)

IMG_2782 by you.

Several of the teams were very evenly matched, with four of the games ending up at 50-to-49!

With about 50 people show up, it was a great night. Thanks to the guys who helped out setting up and packing up, without their help I don’t think we would have been able to successfully pull of the night!

Congratulations to Cobra Commanders (from Deakin!), who took out first place. Sabo, Camberwell Clowns and Silhouette took out second, third and fourth respectively. 

See the rest of the photos up on flickr


Comments Off
 

Zune sums up everything I hate about Microsoft

16 September 2009 Tags  , ,

image

With yesterdays launch of the Zune HD’s and the new Zune Software (4.0), it didn’t take me long to realise everything I hate about Microsoft can be summed up by using Zune examples.

1. Stupid region restrictions

Neither Zune HD or regular Zunes are for sale outside North America. Likewise, the Zune Pass isn’t available outside of NA. I know plenty of people who would drop their iPod for a Zune and the Zune pass, the music subscription model is an awesome idea, and the Zune HD is some awesome looking hardware.

america-sees-world

I know the above is the factually correct representation of the world, but I really wish us dragons could give them money on a monthly basis so we could listen to various monster rock songs.

2. Bloatware

iTunes, 89meg; Songbird, 13.3meg, WinAmp, 9.8meg… Zune Player? 131meg – and it comes in x86 and x64 separate downloads. In typical fashion, Microsoft just have to have the largest program available. Why is it so big when most of it is visualisations and data pulled from the web? That brings me to my next gripe..

3. Custom UI framework – not WPF

Why is the Zune Player 131meg? Probably because they’ve implemented their own private UI framework based on Media Center rather than using Windows Presentation Foundation (WPF), the framework we are constantly reminded of being "good" for media and the like.

WPF is supposed to be the successor to WinForms in .NET. It can use vectors for the interface, has hardware accelerated support, pixel shader support for effects… but where has Microsoft used it? Well, there is Expression Studio (a suite of applications for… making WPF/Silverlight apps) and the unreleased Visual Studio 2010 (…a program for developing WPF/Silverlight apps amongst other things)… I can’t think of any other examples.

The apparent lack of faith in their own framework leaves us WPF developers scratching our heads and wondering if we should be calling it quits on WPF, or striving on when they finally iron out a considerable number of the show stopper bugs (virtualisation problems, resize performance problems, text blurry problems) in .NET 4.0 (or possibly later!)

4. Overlapping Products

Instead of being content with just one media/music playing application, Microsoft have decided to reinvent the wheel and have two separate programs. Zune Player and Windows Media Player (WMP). It’s be great if the features in Zune Player were a super-set of those found in Windows Media Player 12, but it lacks a host of features found in the latest (and even some found in the previous) version of WMP.

  Zune Player Windows Media Player 12
Handles multi-disc albums Yes No
Has DNLA Support No Yes
Has Windows 7 Support Yes Yes
No, really, Win7 support including Libraries No Yes
DVD Support No Yes
Detects Folder.jpg Sort of Yes
Detects folder.jpg hidden by WMP No Yes
Syncs Zune Yes No
Syncs other mp3 devices using MTP No Yes
Has "similar song/artist" playlist Yes (Smart DJ) No
Has "autoplaylist/smart playlist" Yes Yes
Plays Internet Radio playlists No Yes
Has taskbar mode Yes No (But WMP11 did)
Search-as-you-type No Yes
Podcast support Yes No

The above shows that unless you really want the pretties or the few features WMP is lacking, there isn’t much in the way to convince me to use the Zune player.


9 Comments
 

MahTweets v2.5 Beta

9 September 2009 Tags  

MahTweets v2.5 Beta 4 was released a few days ago, the entire 2.5 series has only been publically floating around for a couple of weeks, and we’re just about to hit 300 users (according to the Twitter OAuth control panel)

Capture

This version isn’t just me – a big thanks to the team of WillHughes, NickHodge, UXLuver and Shiftkey – those guys have really made MahTweets awesome.

So what are the big changes from the earlier 2.0 release? Well, it’s been nearly a complete rewrite.

  • Multiple account support
  • Facebook support
  • Extensible, plugin based architecture using Managed Extensibility Framework
  • Url shortening
  • Multiple uploading services (Flickr, Twitgoo, Twitpic, Yfrog, Thumbwhere)
  • Theme support
  • Multiple column support
  • OAuth authentication for Twitter, and over HTTPS/SSL meaning MahTweets is more secure than most of the other clients out there
  • IronRuby support

Don’t forget the other fairly awesome features like

  • Webcam support
  • Quick adjusting/filtering of columns
  • Open source under MS-PL license

This version has been getting some good press too!

"the rest integrates a very few functions and only allows a maximum check for updates, and post new tweet.

But now we have a valid alternative, that even though developing, already shows its remarkable quality."

via TuttoVolume.net

Want a good Twitter client for your Windows system that doesn’t necessitate installing Adobe Air? Check out MahTweets.
If you’re willing to overlook the…er…interesting interface, MahTweets is loaded with features.

via DownloadSquad

Then @aeoth create MahTweets. It’s MS-PL. It’s extensible (via MEF). It has IronRuby for scriptable extensibility.

It is awesome.

Use it. Contribute. Let’s make the world’s best WPF Twitter Client.

via Nick’s MSDN blog

If you’ve got any problems or suggestions, head on over to our UserVoice page and leave some comments.

The source code can be found at codeplex, or the installer on the MahTweets feature page.


Comments Off
 

Review: [PROTOTYPE]

7 September 2009 Tags  ,

prototype-1-1280x960

[PROTOTYPE] launched earlier this year on PC, Xbox 360 and PS3, developed by Radical Entertainment. Released during June 2009, it was part of several largely hyped, third person, sandbox games launching this year, including inFAMOUS and Red Faction: Guerrilla. I’m late on my review, I know.

This genre has really been defined and refined by the Grand Theft Auto series – the only true standout in the genre thus far, so there are some unavoidable comparisons.

Story

The story goes something like: You’re Alex Mercer, you wake up in a morgue remembering little other than your name, and discover you’ve got two problems: one, you’ve got super powers, two you’re being hunted because you’re infected/have super powers. These super powers give you the ability to shape shift your body into various weapons and armour, as well as take the form and memories of other people by consuming them.

Given the game is of the sandbox genre, it would be fair to expect [PROTOTYPE] to suffers the same as all sandbox games when it comes to pacing. It’s hard/impossible for the developers to set the pace of the game and story when the player is the one who is ultimately calling the shots. It also makes it harder to tell the story as its being interrupted by the pesky player going off and doing side missions. Unfortunately, Radical took it upon themselves to make it even more difficult on themselves by not revealing all of the story unless you “consume” certain VIPs – who are weak and fleshy and will die if you run into them a little too fast.

Gameplay

Like the majority of the Grand Theft Auto series, [PROTOTYPE] is 3D, but unlike GTA, that really does mean every possible direction and dimension – half the game is played on the rooftops or climbing skyscrapers. While it looks and feels awesome to be gliding or scaling huge buildings at first, it becomes tedious as its a rather slow way to move around a rather large city. Red Faction: Guerrilla suffered from the same problem where transport (cars) was the weakest element in the game.

For the most part the difficulty curve is… absolutely broken. The first level is “somewhat towards the end” of the game, a psuedo-tutorial if you like, where you have all your powers/abilities at your disposal. When the level ends, you go back to retell your story to a shadowy figure, losing all your abilities. Assassins Creed did the same thing, and frankly I find it more frustrating than anything. However, this isn’t what breaks the difficulty curve. The game flipflops between being stupidly easy, and setting you up against boss fights or the like which require 10-30minutes because the opponent has so much health/armour that your weaponry – which carves through tanks – is ineffective. Then throw in a section where you lose your abilities? Yeah. Great.

The control system wasn’t exactly intuitive either, which didn’t help the combat system. The combat system lets you activate a variety of powers, the more powerful “moves” resembling more of a Street Fighter/Tekken combo system which (at least on PC) lead me to do one thing – spam light attacks. It was far too easier just to use the “Blade” and just a general “attack” rather than the “twenty five button combo that cuts everything down, but takes three minutes”.

Overall

There are some genuine highlights in this game that you are very unlikely to see in other games, such as the ability to kick a chopper and make it explode. The novelty of these sort of features runs out quickly as the game shows its a little too repetitive.

Overall the game isn’t bad, I’m happy saying that it is good – but it is not great. The poor story, repetitive gameplay and dull graphics (again, they weren’t poor, but they were certainly not great, and the repetitive scenery did not help) are the main detractors, while sense of freedom, encouragement to destroy everything, and some unique gameplay movements are the attractors.

2.5/5

rating_starrating_starrating_halfstar


Comments Off
 

WPF WTF #3: ListBox/View, Virtualising

5 September 2009 Tags  

In .NET 3.5 SP1, WPF saw some fantastic performance increases including one of my favourites – the virtualising stackpanel (VSP). VSP’s meant that the items in a listbox/etc that aren’t on screen aren’t rendered – they’re virtualised. This provides memory and CPU performance increases.

VSP has two modes, Standard and Recycling, where the latter reuses the UI containers when it can, just changing the content, doing this saves even more memory.

And here is what happens when I enable VirtualisingStackPanel on a ListView in MahTweets.

image

That looks a little more than 140 characters per tweet – it starts combining the text in items. Fantastic.

If I use an ItemsControl (which Listbox/View are derived from), everything works fine – but ItemsControl has its own problems.

Note, this happens with any textbox/RTB I’ve tried in a ListBox/View with Recycling enabled, not just with my fancy ItemTemplates.


Comments Off
 

WPF WTF #2: Opacity

29 August 2009 Tags  , ,

3866195696_feccd17706

On the left is WPF, on the right is WinForms, both have this.Opacity = 0.5; as the only code behind the button.

The WinForms example, as you can see, is semi-transparent and would shown whatever is behind it (if there was something behind it)

The WPF example, however, just "dulls" the contents of the Window rather than making the whole thing semi-transparent. The way to do it is to set AllowTransparency="true". However, that means WindowStyle must be set to None, which means you lose the chrome (the ‘glass’ around it), the minimise, maximise and close button, so you have to create and control those, as well as manually resizing the Window and manually controlling moving the Window.

I tried P/Invoking the Win32 libraries to set opacity and they work perfectly… on WinForms. They fail miserably in WPF.

I’m happy to be corrected if anybody knows a solution.

Opacity earns this weeks WPFWTF award and leaves us scratching our heads with the slogan, WinForms: Back To The Future.


Comments Off
 

Expression Studio 3, XNA Game Studio 3.1 and Robotics Studio 2008 R2 on Dreamspark!

19 August 2009 Tags  , , ,

This was originally posted on the Deakin Student Partners Blog

In the words of Hubert J. Farnsworth, "Good news, everyone!" – Expression Studio 3, XNA Game Studio 3.1 and Robotics Studio 2008 R2 are all now on Dreamspark, free to students! Expression Studio 3 brings some awesome improvements to.. well.. every product in it – Blend 3 + SketchFlow, Web + Super Preview, Encoder now has screencasting.

expression_studio_3_photoscope

Expression Studio 3 Highlights

  • Expression Encoder 3
    • Improved H.264
    • VBR Smooth Streaming
    • Source CODECs
    • Audio Enhancements.
    • Performance
    • Live Encoding
    • Screen Capture
    • Improved profile pallete
    • Silverlight 3 Media Players
    • New player skins
    • API Enhancements
    • Win7 Integration
    • SDK "in the box"
  • Expression Blend 3
    • SketchFlow – Sketch WPF/Silverlight interactive prototypes.
    • Photoshop and Illustrator support
    • Styling Controls: Creating templates from artwork
    • Styling Controls: Creating TextBox Templates from Artwork
    • States: Improved Support for VSM
    • Interactivity: Behaviors
    • Working with and Generating Data
  • Expression Web 3
    • Super Preview – view side by side comparisons of your website in Firefox, Internet Explorer 6/7/8 and more
    • Publish with SFTP/FTPS
    • Improved Photoshop PSD support – import just the layers you want!
    • Silverlight support – uses Expression Encoder 3 to encode (nearly) any video you want to Silverlight and embed on your site!
    • TFS SC support
    • Deep Zoom Composer support


XNA Game Studio 3.1 Highlights xna_20

  • Avatar Support: Render and animate Avatars to use in your game to represent gamers and other characters within your game.
  • Xbox LIVE Party Support: Enabling gamers to communicate, even when each gamer is not playing the same game in the same multiplayer session. LIVE Party supports up to an eight-way group voice chat for gamers and keeps gamers connected before, during, and after a gameplay session, persisting across title switches.
  • Video Playback: XNA Game Studio now supports the ability to play back video that can be used for such purposes as opening splash and logo scenes, cut scenes, or in-game video displays. This set of XNA Framework APIs supports the following features:
    • Full screen video playback
    • Video playback to simple textures in game
    • Control of playback such as pause/resume and stop
    • Retrieve properties of the video, such as playback time, size, and frame rate
    • Determine the type and usage of the audio track, such as if it has music, dialog, or music and dialog
    • Play back multiple video streams at the same time
  • Audio API: 3.1 has a new usage pattern of SoundEffect.Play. Sound instances created by Play calls are disposed automatically when playback ends, and SoundEffect.Play returns a Boolean to indicate success or failure.
  • Content Pipeline Enhancements: improvements making it much easier to add custom types (custom attributes for run-time of an object and run-time type version of an object, and the ability to determine if deserialization into an existing object is possible).
  • XACT3 Support: includes support for XACT3 with new features including the ability to enable a filter on every track, and support for the xWMA compression format.
  • Visual Studio Changes: XNA Game Studio 3.1 supports both 3.0 and 3.1 projects, and it includes support for upgrading projects from 3.0 to 3.1.

Comments Off
 

WinMo 6.5 SDK DVD giveaway

6 August 2009 Tags  ,

IMG_2248

I’ve got 15 copies of the Windows Mobile Developer Tools, which contains everything (minus Visual Studio) you need to get started on enter the Student APPrentice competition.

These DVDs include

  • Windows Mobile 6 Standard and Professional SDK Refresh
  • Windows Mobile 6.1 Standard and Professional Images
  • Windows Mobile 6.5 Standard and Professional Developer Toolkit (which includes the 6.5 Images)
  • Codemason’s Guild Live Meeting videos

It totals up to 1.76gb of SDK goodness, which can be a pain to download.

If you want one of these 15 DVDs, use the contact form on our about page to give me your name and postal address, and I’ll get these out as soon as possible! First come first served basis.

Oh nuts, you don’t have Visual Studio? As a student you can get it for free via MSDNAA from your University or from Dreamspark.


Comments Off
 

WinMobile "Debug" Events

3 August 2009 Tags  ,

 

If you’re interested in the APPrentice competition but have questions on the inner workings of the Windows Mobile Marketplace? Well, the Codemasons guild are holding a series of (free, I think) events on down the east coast of the country.Codemasons_2

Next week we will be holding a series of events to help developers get their application development moving for Windows Mobile 6.5 and into Marketplace.

These Debug Days will be held from 4.30pm till 9pm on;

  • Monday August 10th – Microsoft Brisbane, Level 9 Waterfront Place, 1 Eagle St, Brisbane
  • Tuesday August 11th – Microsoft Sydney, 1 Epping Road, North Ryde
  • Wednesday August 12th – Microsoft Melbourne, Level 5, 4 Freshwater Place, Southbank

We will provide an update on Marketplace, the signup/registration process, and the guidelines.

The evening is then over to the developers – so what are the topics you want out MVPs to cover – let us know;

  • post your comments to this post
  • Tweet James McCutcheon or Nick Randolph on Twitter

We’ll update the topic lists here @ WMOZ, @ the Codemasons’ Guild, and James/Nick will Tweet as well.

Rego links coming soon – but slot some time in your diary.

PS – we’ll have some drinks & food on hand as well :-)

via WinMoOZ


Comments Off