ASPxGridView, MS Ajax and XYDataSource

If you use [DevEx] ASPxGridView within MS Ajax' UpdatePanel (ASPxGridView.EnableCallBacks="False") you should be aware that you should perform DataBind() method within OnInit method (Init event). Otherwise editing just won't work, or better, it works, just the modifications aren't persisted. It took me some time to pinpoint the problem as ASPxGridView worked just fine outside UpdatePanel. I had to put it within UpdatePanel because I needed to refresh other controls as well (otherwise grid refreshes just itself).

Note that when ASPxGridView is hosted in UpdatePanel the nice error reporting feature (see the picture below) won't work either - instead you'll get script error reported by browser. IOW you have to handle errors by yourself.

image

Cool automatic error feedback

See also this support thread.

The time of "Vote for XY product" is here again

asp.netPRO started voting process for asp.netPRO Readers' Choice Awards 2008 as they do every year. And all of the 3rd party component vendors are asking for your vote, as usual. Nothing wrong there. But there are two things that I noticed during my voting. First, immediately on the top of first page, I saw this product:

image

This refactor tool was around at the time of Visual Studio 2002/2003 and died soon after, or better it froze. The web site is still there and you can even download it for free (Order tab). It was a great product at that time, offering refactoring when nobody else did. However the product is dead as the dodo for many years now. So I wonder, why is such product even listed as a choice?

The other odd thing is the categories. For example, Component Set category lists a lot of different sets. I mean different like apples and hard disks. How can one compare those? Or Utility category where the difference is even huger - looks like basically everything that didn't fit in other categories landed here. Go ahead and compare Aqtime profiler with dtSearch with LLBLGen Pro. Which is better? I think the products with larger client base will get more votes simply because it is natural that you would vote for product you own in such case.

What gives? The results in at least the two categories mentioned can't be relevant if you ask me, or better, they'll just reflect the client base size of each product.

Building your own Media Center

Since I have IPTV I am really annoyed by not having an option to save programs, like in old video recorder and cable network days. True, one can still save using video recorder, but the problem is that video recorder can't change channels on STB (set top box) and thus you are limited to a single channel. Pretty much useless. The other option is using personal recorder, a feature provided by my IPTV provider. But again, the drawbacks are enormous: there is a monthly fee, you are limited to 6 hrs of total saved content. Even worse limitation is that your content can be stored for maximum of two days (forget vacation, or drive back to home every two days to watch the saved content). But there's another drawback, in fact mother of all drawbacks: only a few channels and not all shows on those channels are allowed to be saved. Total useless crap.

Hence the idea of my own media center. After all I live by using my development skills, why not use them for this one. So, RH Media Center project was born.

The main objectives:

  1. ability to save from IPTV
  2. ability to schedule saving
  3. ability to playback saved content
  4. ability to control RH Media Center by remote

Hardware requirements

  1. A computer (server which is always on preferably) that will be used to save content
  2. A computer to playback the saved content (possibly attached to TV). In my case this is my laptop.
  3. A PocketPC device (remote control)

1. and 2. can be the same computer, whatever is feasible for you.

Implementation

VLC media player ActiveX control is at the core of RH Media Center. VLC media player is a free, open source, cross platform application that plays just everything out there, including SIOL IPTV streams. And luckily for me, they have an ActiveX control, too. In fact I've build my application around this ActiveX control using Windows Forms UI. Here is how it looks:

 image

Video (both IPTV stream and saved content playback) is rendered and saved by VLC. You can also see a bunch of controls on the top and the channel listing on the right. There is also saved content listing in the docking panel next to channel listing.

image

Test saved contents listing

Note that UI is pretty rough at this time as prettiness wasn't one of the objectives. Anyway the objectives 1. and 3. are done now.

Scheduling

Once the core functionality is done (see above) the scheduling is pretty easy. The application should parse command line arguments and start saving given channel for given time. The content file name should be made of given argument (i.e. name of the show) plus date. Here is an example:

RhMediaCenter.exe rec "Channel" ShowName 120

This means that content from "Channel" will be recorded for 120 minutes to a file name

ShowName_hh_mm__dd_MM_YYYY.ps

ps is MPEG-PS extension. You'll note that I didn't specify when should the recording start aka scheduling. This step is done using Task Scheduler - no wonders there, just run that command line at any time you specify and that's it. A bit rough to configure but it works just fine (in future I'll enhance the configuration step).

Remote control

Every decent media center has remote control capabilities. How can you skip those commercials otherwise? I've figured out, that I have a bunch of PocketPCs lying around and collecting dust. At the same time I have a Wi-Fi network at home. Get the idea? Yes, I'll use PocketPC over Wi-Fi to control my media center. The technology of choice is WCF which is partially supported with .NET Compact Framework 3.5. BasicHttpBinding, here we go.

So I've build a simple Windows Mobile 6 application which looks like this:

image

It allows to connect to preferred RH Media Center through providing a proper IP, it can get a list of saved content and it allows you to play any of them. It features also a Pause button and move forward (left group of buttons) or backward (right group of buttons) for a given time span. And after creating a hole in Windows Firewall on computer where RH Media Control runs it just works.

The only problem is how to build WCF service client code for .net compact framework. This feature is provided by Power Toys for .NET Compact Framework 3.5's NetCFSvcUtil utility that does the similar job as Service Metadata Utility (SvcUtil.exe) for .net framework.

Conclusion

I solved the biggest IPTV issue - saving programs and playback of saved content using a remote control. By using .net 3.5/Windows Forms/WCF/Compact framework and VLC ActiveX control it took me only around 10 hours of total time over the weekend (most of the time I used for plumbing , user interface and figuring out VLC ActiveX oddities). If you wonder why I'd used Windows Forms instead of WPF: because I was experimenting at the beginning (and the project is still an experiment) and I have no 3rd party controls for WPF yet - so it was easier with Windows Forms. In future I'll be definitely using WPF.

I have to say that .net/VLC made it so easy to build this pet project - the ease of putting pieces together is amazing.

BTW, Is anybody interested in binaries? (I am not saying I'll provide them nor that I won't provide them :-))

"The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly." annoyance

Did you ever encounter this dialog box when dealing with WCF services?

"The target assembly contains no service types.  You may need to adjust the Code Access Security policy of this assembly."

It might happen when you run application at debug time. It is highly annoying and time consuming (it pauses application for more than one minute without any apparent reason). But what does it mean and why does it happen?

When you create a project from a WCF project templates Visual Studio knows that this project is a WCF service and thus it offers two debug time helpers: WCF Service Host and WCF Client. These two guys are intended to help you with running and testing WCF services without writing any code - they just appear at debug time. So far so good. But why the annoying dialog?

The dialog in question means that you have a project, created using one of the WCF project templates, with an interface marked with ServiceContract attribute and in the same project you don't have a class that implements this interface (perhaps you implemented that interface in another project). So, the WCF Service Host can't find a suitable class to host the service and it complains through that dreaded dialog box. Note that WCF Service Host is pretty dumb and it is incapable of searching through other projects in same solution. OK, the solution is to stop running WCF Service Host or even better, instruct it which class implements the interface in question. Well, AFAIK the later is impossible while the former can be done through project file modification using notepad. Here is how:

Delete this line from your project file:

<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

And you won't see WCF Service Host or dreaded dialog anymore.

The question is, why didn't [MS] think of these scenarios before?

BTW, if you just want to stop WCF Client from runing then delete this command line argument: /client:"WcfTestClient.exe", created by WCF project template.