ailon's DevBlog: Development related stuff in my life

Get RSAKeyValue from Base64 Encoded Public Key

4/27/2010 6:54:55 PM

Note: I don’t know much about encryption and certificates. This is not a tutorial or good explanation of things. It’s just a note to myself for future reference.

I needed to verify data sent to my ASP.NET app signed by 3rd party using their private RSA key. They’ve sent me their public key in base64 encoded form. You’ve probably seen it many times. It looks something like this:

-----BEGIN CERTIFICATE-----
MIIECTCCA3KgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBujELMAkGA1UEBhMCTFQx
EDAOBgNVBAgTB1ZpbG5pdXMxEDAOBgNVBAcTB1ZpbG5pdXMxHjAcBgNVBAoTFVVB

-----END CERTIFICATE-----

Problem is (as far as I understand) to verify data using RSACryptoServiceProvider you either need the key installed on your system or have it in XML Signature format. I’ve searched high and low for a way to convert that encoded key to XML equivalent but couldn’t find a simple way. Most likely I wasn’t searching for the right thing and I admit I’m not an expert in this area. I guess this can be done some other way but after combining some breadcrumbs I found here and there I came up with only 3 lines needed to to get <RSAKeyValue> representation of the key:

   1: byte[] binaryCertData = Convert.FromBase64String(mimeKey);
   2: X509Certificate2 cert = new X509Certificate2(binaryCertData);
   3: string xmlKey = cert.PublicKey.Key.ToXmlString(false);

And that was it. Does the trick.

Update: I’ve created an online tool to convert Base64 encoded public key to XML Signature format.

Tags: ,

Debugging Silverlight Out-of-Browser Applications on 64-bit Windows

4/22/2010 3:53:52 PM

Today I had to debug a problem in my Silverlight 3 project that manifested itself exclusively in out of browser mode.

Here’s a concise and to the point guide on debugging Silverlight 3 applications in out of browser (OOB) mode by Jimmy Lewis. Problem is that when you follow it in Visual Studio 2008 running on 64-bit Windows 7 (and as far as I understand Vista too) you get this message box when you try to start debugging:

Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficent capacity allocated to the StringBuilder before marshaling it.

I’ve tried to search for a solution on the web and all I found was a simple but not very satisfactory workaround: Use VS2010.

Yes, as far as I can tell the only way to debug your Silverlight 3 OOB app on Windows x64 is to open it in Visual Studio 2010. Problem is that first of all you need to have VS2010 and another problem is that it has to convert your project to 2010 format.

Luckily in my case I was able to just copy my VS2008 project to a new location, open it, convert it, quickly find a lame bug (I was assuming in one place that HTML Bridge is always available), implement single line fix and copy it back to my VS2008 project. So it was a small inconvenience in my case but if I ever need to debug something more substantial that could be a big pain.

However it’s quite possible that my googling skills aren’t perfect and I’ve missed a real solution to this problem. If so, please, let me know in the comments below.

Tags: ,

Samsung C650 TV Review

4/15/2010 6:18:00 PM

IMG_4620

Preface/Buying decision.

This is not the right place for this review imageand I’m not a TV reviewer but I have bought a LE40C653 Samsung TV a couple of weeks ago and there were absolutely no reviews for it at that moment. Hell, it wasn’t even listed on any of the Samsung’s sites 2 weeks ago (and I’ve checked like 15 of their localized sites). So, I decided to write this here to put some opinionated info about it on the net.

I’ve left screen size, localization (first 2 letters of the model number) and last digit (which denotes design related specifics as far as I understand) from the title since I’m going to primarily write about the internal hardware/firmware related features for the most part of this review and all these specifics don’t matter here. That said I find C653, C654 and C670 modifications to be incredibly beautiful and C650-652 – not so much. I’m just a sucker for rectangular TV shape and all the “sticking” elements turn me off. BTW, C stands for 2010 model year, B – 2009, A – 2008.

We bought this TV semi-accidentally. We’ve decided to buy a new TV since our old CRT LG started showing signs of near death and investing in it’s repair didn’t seem as a good idea to me.

The size of the TV was basically dictated by features/price formula. I figured that I don’t really want to sacrifice size for going LED, 3D or some scientific picture quality improvements and I don’t want to sacrifice features (which are actually 90% of my joy from this purchase) just to get a big-ass dumb/ugly/oldish TV. So having 800-900 Euro budget (~$1000-1100) I’ve settled comfortably in 40”-42” category.

I did my research on the internet and narrowed my choices down to 3 TVs: Sony Bravia KDL-40EX500, Samsung LE40B650 and LG 42LH5000. All of them had ups & downs judging by specification. Sony had a limited media file format support and only one USB (more on this later), LG had no network connectivity. Samsung looked the best on paper. But I could’ve lived with any of these.

Next step was taking my wife to a physical store to say her final word based solely on the looks. I was generally indifferent to the design aspect but even I wasn’t impressed. LG had some lame backlit pimple around it’s power button (or whatever that was), Samsung had triangular bottom which looked kind of cheap and already dated, Sony actually looked quite good but very basic. Wife urged me to go to another store. I almost yelled at her. After all I did my research on the internet. There are no other TVs compatible with my requirements and budget in the universe! But since the other store was just across the street I gave in just to be over with this argument.

We went into that store and there it was – awesomely beautiful and (almost) within our budget. The only problem was that I haven’t seen anything on the internet about these mysterious Cxxx models. I went back home and started my research all over again. Samsung.lt, .co.uk, .ie, .de, .ru – nothing. Google – only few pages on some random obscure sites. I had to get official specification through “my secret channels”. Never thought I’d need to do that for a TV.

So, the specs looked good. Basically they are the same as for B650 models. No major changes as far as I remember. I decided to act while under the influence (not a generally good idea), went to that store and bought it.

Since this was my first TV of this size I was concerned if I could fit it into my car and carry it home from car without help. I’ve called 2 of my friends who had 37” TVs and they both assured me that it most likely wont fit into my car (midsize sedan) and I’ll definitely won’t be able to carry it alone. The sales guy in the store said absolutely the opposite. Apparently there were some EU regulations in recent years forcing manufacturers to minimize packaging materials, so the boxes became smaller. And the guy was right. It fit easily and I (average size nerd with back problems) was able to carry it alone without any problems.

Design.

As I said, the TV is beautiful. After seeing it I went from design indifferent to totally drooling over it. Basically it’s an LCD screen beveled with black plastic inside of glass cover. Plus there’s a hardly visible brushed metal bar behind that glass at the bottom with sensor controls on it. That’s it. I was actually surprised with this minimalism coming from Korean manufacturer. My stereotypical vision of both LG and Samsung is that they can’t resist placing some fancy but tasteless element on their appliances. But this is not the case here.

Picture Quality

I’m not a picture analyst. I don’t care about levels of black and or white in test conditions. All I have to say is that picture is awesome enough for my layman eyes. The only odd effect I’ve seen so far is that higher quality movies look kind of like filmed with HD handy-cams. I mean there’s no that artificial film effect/blurriness I’m used too. Not sure if this is in any way related to this particular TV model and/or technology.

Update: the "handy-cam" effect is caused by Motion Plus feature. Turned it off and movies look like movies now. Not sure what effect that will cause on motion scenes, etc.

Television.

Actually one of the less than perfect experience with this TV comes from actually watching and managing TV channels :) Sounds like the story with smartphones. Most of them tend to forget about their primary feature of being a phone. Something like this happens here.

I’ve never had a TV with built-in digital TV tuners before so maybe there are some unsolvable technological problems here. If so, I apologize for what comes next.

It looks like channel management for digital and analog channels was written by 2 completely different teams who didn’t even know that the other team existed. Then those 2 pieces were assembled into one system by some third team using duct tape. I don’t know why you can have two #1 channels (one digital, one analog) and to this day I don’t know for sure how to switch specifically to digital #1 or analogue #1 using numeric keypad. There’s nothing about this in a pretty thorough user manual either. You can change channel numbers for digital channels but you can only move analog channels around. And you can’t mix digital with analogue. I guess I’ll just move digital channels to 100+ numbers and leave analog below 100 ( there can only be 99 analogue channels).

Maybe that’s just a specific situation here and now. I understand that analog TV is going away and no one invests too much thought into it these days. But I have a cable provider who feeds me something like 50 analog channels. In addition to that they feed me like 20-30 digital channels with some of them being just a digital version of those analog channels. I can subscribe to a more expensive package that will cover my analog range with digital versions. The problem is that those are for the most part of the same SD 4:3 picture quality just sent via different technology. The only upside is that some of them have digital TV guide. And I’m not very interested in paying extra for that.

What I would like to have is a way to place digital versions of channels in place of analog and intermix them with other analog channels. But I can’t and I guess this will resolve automatically in a couple of years when analog goes away completely.

Network Connectivity

The TV comes with LAN (Ethernet) port. Wired network connection is basically setup-free and worked immediately. The problem is that I was dumb enough 6 years ago when reconstructing my place not to envision the need for Ethernet socket next to my TV. Fortunately TV supports Samsung‘s proprietary USB Wi-Fi dongle. While making only their own dongles supported kind of makes sense (drivers and stuff), pricing of said dongle doesn’t. List price is something like $75+shipping.

Somehow I imagined these things would have to be pre-ordered and overpriced in local stores (forgot to ask when I was buying the TV) and ordered one on eBay, just to find out a couple days later that it was easily available and even cheaper in the local store. Anyway, the dongle arrived, I’ve plugged it in and again it worked seamlessly and very smoothly (just had to enter my router’s pass phrase).

It’s a great thing Samsung has 2 USB ports. Sony had only one. So I can have my USB wi-fi dongle and USB HDD/stick plugged in at the same time.

I have 802.11g router and the dongle supports 802.11n so I was contemplating upgrading my router in case there are some noticeable speed problems. To my surprise I was able to play 1080p (obviously compressed) MKV over the 802.11g connection absolutely smoothly for like 2 hours without a single glitch. So I’m not upgrading my router for now.

Media Player

IMG_4625

I was totally surprised when media player in my TV (which is obviously a secondary feature) put to shame WDTV I have in the other room. WDTV is good, but it can’t decode DTS sound (for example) and this TV can.

The TV can play media over the network using DLNA protocol too. If you have Windows 7 on your PC this works right out of the box. For earlier versions of Windows there’s Samsung’s PC Share Manager software and a bunch of 3rd party software. Funny thing was that I couldn’t see any Matroskas over DLNA. I’ve googled the issue and found out that it can easily be solved by simply changing file extension from .mkv to .avi. Not very elegant but very simple.

But there’s a huge problem with playing media over DLNA. There’s basically no navigation in the file in DLNA mode. You can skip 20 seconds in a single button press but you can’t even chain these presses and it takes like 2 seconds for player to resume playing and only then you can skip another 20 seconds. So if you switched from the file you were viewing over the network there’s basically no reasonable way to get back to where you’ve left. This makes watching movies over DLNA practically unusable. This could be a problem with Windows implementation of DLNA but I’ve tried other 3rd party DLNA servers with the same results at best. So this must be either some stupid limitation in DLNA protocols or most likely implementation problem in Samsung’s player.

Update 2010-04-20:  I've installed Samsung's PC Share Manager and now I got chaptering and resuming over the network. Still no normal fast-forward/rewind but pretty usable already. And you don't have to rename .mkv to .avi either.

Another annoying issue with media player is that it’s very easy to pop out of it and it doesn’t save state. So if you were watching a movie and accidentally or on purpose switched to TV you’ll have to relaunch media player and manually navigate to the file you were watching. Fortunately it remembers previous location in that file in USB mode.

Overall I’m impressed with this media player but these 2 issues are very depressing. If anyone from Samsung is reading this, please, forward this to whoever is in charge and fix it. If you fix it I’ll love you eternally ;)

Internet@TV

IMG_4626

When I read something like YouTube, Twitter, etc. support in feature descriptions I had a little smirk on my face. Riiight, I thought. Like it could be usable. To my surprise it’s totally usable. Some apps more than other but in general color me stunningly impressed.

I’m very glad Samsung didn’t go the way of Nintendo on Wii. Including real browser in an appliance is wrong. Navigating such app is a total pain. Samsung went the other way. They just made an app ecosystem and an app store (coming to full speed in summer, 2010). The choice of apps is quite limited right now but there are apps for YouTube, Twitter, Picasa, Associated Press, AccuWeather, etc. And as far as I understand there are apps for Netflix and Pandora in USA and BBC iPlayer in UK (not sure, cause I can’t check them).

YouTube app is awesome. It plays videos smoothly both in a window and fullscreen and even searching for videos on a simple numeric remote is not a big problem thanks to autocompletion in search box. Very cool.

IMG_4627

IMG_4628

Twitter app is surprisingly cool too. Sure, typing a tweet on a TV remote is not a simple exercise but it supports T9 so it’s not harder than typing an SMS on a mobile phone. I’ve managed to type one :) And reading your timeline is perfectly comfortable. The only problem is that you can’t follow the links (no real browser, remember?)

 IMG_4632

Same goes for Picasa app. Simple + useful = awesome. I was able to start a slideshow of my photos form PicasaWeb in no time. And I guess it was even easier than watching photos from USB using media player.

Sure, there is a couple of things I didn’t like. From what I saw about 2009 Samsung models, most of the Internet@TV apps were sort of widgets. These widgets were displayed on top of regular TV broadcast (correct me if I’m wrong). Most of the apps on my TV are full-screen. This totally works for YouTube and Picasa, but I would really like to have a twitter widget with new tweets popping up while I watch TV. And switching away from TV just to check a full-screen weather forecast in AccuWeather doesn’t look like the best possible user experience.

I saw only one app that works in a widget mode – Associated Press. You watch TV and have a news reel running at the bottom of your screen. Pretty awesome if you ask me. And that proves that this kind of functionality is there. The only question is why it’s not utilized in, say, Twitter app?

IMG_4633

 IMG_4634

IMG_4635

Conclusion

I’m very very very satisfied with my purchase so far and can easily recommend Samsung’s C650 or higher models to anyone. If you care about media play and internet apps make sure that you don’t go below 650 model cause it won’t be there (or be there only partially).

If anyone from Samsung is reading this, please, let media player team know about my issues above and if they can address them I’ll be extremely happy and grateful. Frankly, this TV is probably the most exciting home appliance I have ever owned.

Tags: ,

VisualStudio.NET vNext Feature Request: Multi-target IntelliSense

4/8/2010 6:44:04 PM

Visual Studio is great. IntelliSense is great. But here’s one thing that has been slowing me down ever since I started developing for several .NET based platforms.

The Problem

WPF, Silverlight and now Silverlight for Windows Phone 7 are very similar frameworks, but they are far from being identical. Lots of code written for one can be re-used in another, but quite often it requires small modifications and it’s frustrating. It’s especially frustrating when you realize that those modifications wouldn’t be necessary if you’ve used another overload of some method or used another method altogether in the first place.

Take a look at screenshots of the IntelliSense dropdown for the same class in different environments:

Here’s one for WPF 3.5:

wpf_dropdown

And this is on for Silverlight 3:

silverlight_dropdown

Notice that there are lots of methods, properties and events that are not in Silverlight and I guess you can find some that are not in WPF (but that is not the point here). Sometimes you want to use WPF-only stuff for better performance or other very valid reasons but quite often you just use it unconsciously because finding out if something is supported in Silverlight or vice versa takes too much time and effort.

Now I wanted to add a LineSegment to the PathFigure and it has 3 constructor overloads in WPF

wpf_overloads

but only only the default constructor in Silverlight

silverlight_overloads

If I haven’t checked for the difference manually (or knew it by heart) I would end up rewriting this code once I’ve switched to a Silverlight project. So, you get the picture. The fact that I constantly have to recompile for all the platforms and/or manually check for differences takes a significant amount of my development time. I would like this to be addressed somehow and if some third party tool does something good in this area, please, let me know in the comments, but for now I have this idea/feature request for future version of Visual Studio .NET

Multi-target IntelliSense

There are numerous ways how this could be implemented and I’m not the best expert in things like this, but I’ll try to explain my vision of this anyway.

I think a project could have a set of secondary Target Framework settings. When these are set, IntelliSense would somehow highlight members or overloads that are in main target framework but not in the secondary. For example WPF methods that aren’t in Silverlight could be grayed out in the dropdown above. Same goes for method overloads. Plus some text explanation in the tooltip wouldn’t hurt too.

Something like this would be a huge time saver for me and I guess for other developers too. Especially with all the extra framework partitioning related to release of Silverlight for Windows Phone 7 which will be another very close yet not completely identical addition to the current mix of WPF & Silverlight.

I’ve ran this idea by Jesse Liberty at MIX10 and he thought it wasn’t a bad idea at all, so I decided I need to submit it to Microsoft via MS Connect. So if you like this and would like something along these lines implemented in the future version of Visual Studio, please, go there and vote it up.

Shout it

Tags: , , ,

Ghost Lines in Silverlight

4/7/2010 4:30:00 PM

Some pretty strange bug in amCharts has been reported to me. In one scenario user got 3 graph lines when zooming-in deeply on a single line graph.

While investigating this bug I found out that previous data point in that scenario was far apart from the one in view and a line was drawn from that previous data point to the current one. The calculated X-coordinate of the previous data point was something around –89000 in my test case so I became curious if this a little crazy coordinate value could be the source of the problem.

I made a very simple Silverlight 3 user control with this simple XAML:

   1: <Canvas>
   2:     <Line X1="-50000" Y1="10" X2="500" Y2="110" Stroke="Green" />
   3: </Canvas>

Here’s what you get when you run this app:

image

 

It looks like even though X1 is supposed to be of type double it rolls over what appears to be Int16.MinValue limit. Tried this in Silverlight 4 RC with exactly the same result. Surprisingly (actually not surprisingly at all) this exact code works as expected in WPF.

Searching around the web produced a couple of results dealing with something that appears to be manifestation of the same issue but in different scenarios and with different outcome.

I wasn’t able to locate any mentions of these limitations in the documentation but I must admit I wasn’t looking hard enough to say that it’s definitely not there.

I’m not sure if I should report this as a bug somewhere provided that one of the posts above is on official Silverlight forums and there are no official answers to it. What I know is that we – Silverlight developers – have to account for this issue in our code and make required approximations ourselves (as in my case) or impose limits on users (as in cases above). So just beware of this oddity.

Some official or just informed word on the issue wouldn't hurt either.

Shout it kick it on DotNetKicks.com

Tags: , ,

Copyright © 2003 - 2017 Alan Mendelevich
Powered by BlogEngine.NET 2.5.0.6