Get all WinRT application from regular Desktop application. Part 1.

Today I’ve been solving interesting task. All my investigation I’ll write on this article. A problem is following: there is a regular C# application which should display all installed WinRT application per user.

There is a whole section of all WinRT APIs for Windows 8 that are able to be called from a regular C# application on MSDN. This one includes a PackageManager class which allows getting all installed packages.

Access WinRT API from Console application.

First step, create a usual Console application.

Then we need reference a Window.dll. However, in the desktop projects Windows tab doesn’t appear by default. For this we need manually add following lines to csproj file.

After that step a new tab will appear:

Now we can try to get all WinRT installed packages. However, when we build that we will have following error:

The type ‘System.Collections.Generic.IEnumerable`1<T0>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

Unfortunately this assembly doesn’t present on reference tab. For this you need add this assembly from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5 folder.

Get all installed WinRT application per user.

We will get installed Metro/Modern packages per user because on same computer different users can install different applications. All this information is available by PackageManager class.

var packageManager = new PackageManager();
var metroApps = packageManager.FindPackagesForUser(WindowsIdentity.GetCurrent().User.Value);

That’s all and really simple, isn’t it? 😉

Advertisements

Hide inactive cursor behavior.

In this article I’ll explain one way how to hide a cursor after n-seconds of inactivity though WPF behavior mechanism. Same effect you can observe on almost any video player — if you don’t touch a mouse for the few seconds, cursor will disappear.

First of all, what is a behavior?

A behavior encapsulates pieces of functionality into a reusable component, which we later on can attach to an element in a view. Emphasis is on reusable. Behaviors also have the benefit of keeping the MVVM pattern intact, since we can move code from code behind to behaviors. You can find a good introduction on the behaviors, type of behaviors in a great article of Robert Hedgate.

Implementation though attached behavior.

Advantage of attached behavior is that it can be used in a native windows store app. Disadvantage is that it does not show up in Blend under behaviors, and thus cannot be attached if you are using Blend. In my case it’s very important to have possibility of using it on windows store app.

In the implementation of the behavior we have 4 dependency properties:

  • Interval — time interval after which cursor should be hided.
  • IsEnabled — enable or disable behavior functionality.
  • ActiveCursor — cursor type when it’s not active.
  • InactiveCursor — cursor type when it’s active.

Logic isn’t really complicated so you just can download it from my Bitbucket.

My podcast list.

This article is not a deep technical but it would be useful for .net developers. Today I would like to write about my podcast list and hope I’ll get a feedback with podcasts which are good for you.

So what actually I’ve on my iPhone:

.Net-development:

  • .NET Rocks (English) — this is my favourite .NET podcast also this one is the oldest one. There is a lot of new information, always fun and interesting. Carl Franklin and Richard Campbell are doing a great job.
  • herding {code} (English) — also interesting and useful podcast with a variety range of topics.
  • Dot Band (Russian) — this podcast first of all interesting because I can get feedback about .NET rumours in Ukrainian community.
  • Hanselminutes (English) — no comments, this is just a Scott Hanselman!
  • Radio-T (Russian) — an interesting podcast about IT world trends.

Because I’m not a native English speaker my list also includes some of the English learning podcast:

If you need more, Scott Hanselman also has a great list of .Net podcasts. You can find it here.

I’m pretty sure that there are lots of other good podcasts. However, this list gives me a lot of interesting and new information. Also our time schedule is not as flexible as we want, however I can listen this whole list on a week. Unfortunately for now I don’t have a time to add one more a good podcast.

I’ll try to keep this list up-to-date.

MailMessage tool for sending any attachments at Windows Phone.

Just for fun or maybe every C# developer should play with Windows Phone; however I’ve started to develop my Windows Phone application. I wouldn’t say about an idea of the application, but as usual there are an email sending and some social functions.

I was really surprised that EmailComposeTask can’t send any types of attachments and EVER html! The reason of it is that all Tasks at Windows Phone SDK are limited by 64k (for example EmailComposeTask’s message body can’t exit of this size).

So I was thinking about following approach:

  • send data to a web service that forwards the file to an email address;
  • upload file to the some cloud storage;

Fortunately I’ve found a great tool which solved all these obstacles. This is a MailMessage (now there is a 1.2.1 version). You can easily send any type of attachments (pdf, mp3, wav, mp4, avi, bmp, txt, zip, jpg, png…) from your application and ever html with the MailMessage library.


Also it has an extremely fast and good support (which is on my opinion the one of the significant characteristic of good tool). I don’t want to add some code example here because everything what you need you can find at product page.

Thanks for the great tool!

Team Foundation Service at the cloud. Setup continuous integration with Microsoft and non-Microsoft test provider

Today I’d like to write about a new offer from Microsoft — Team Foundation Service in the cloud. For now everything is free so this is a great time to play with this technology.

After great success of cloud-version source control I was 100% sure that Microsoft has to react and give their service. Especially because they have already a good product like TFS (after Perforce I really love TFS J). As I said for now TFS is a preview so everything is free. At 2013 a new price will be announcing. However, free plan will include max 5 users at system and some limit for builds (which in my opinion — ideally for small start-ups and freelancers). Previously I used Dropbox + SVN for all my freelance/home projects. Then I’ve switched almost everything to Bitbucket. However, all of this solutions don’t have continuous integrations, test runner and project planning (especially for agile, where TFS always was much-much better then jira).

In this article I’d like to show how easily we can create a simple application, host it at TFS in the cloud, setup continuous integration for each check-in and use not Microsoft test framework. Continue reading

TechDays 2012 at Brussels, Belgium

February 14-16 was fantastic conference at Brussels, Belgium. Also it was the biggest conference when I’ve ever been.

Just have a look at these speakers:

  • Scott Guthrie is a Corporate Vice President in Microsoft’s Server and Tools Business division,
  • Nick Harris is a Technical Evangelist at Microsoft specializing in Windows Azure,
  • Ben Riga is Senior Technical Evangelist for Windows Phone 7 in Microsoft’s Developer and Platform Evangelism (DPE) group,
  • Steve Sanderson works as a program manager for Microsoft in the team that brings you the ASP.NET technology stack,
  • Jeff Prosise is cofounder of Wintellect (www.wintellect.com)

and lots more interesting speakers.

This is absolutely fantastic, isn’t it? J You can find all videos from this event here.

There were a lot of question at the beginning of the year. What is the main way/trend of Microsoft? Is it real rumours about JavaScript (I remind that it was only February!)? And as usual what interesting features were prepared for as from Microsoft?

Let’s give short answer on these questions.

First of all, before this year everybody say that main language at Microsoft stack of technologies was C#. After TechDays 2012 I’d say: now there are 3 equal programming languages C#, C++ and JavaScript.

Yes, JavaScript became strong language at Microsoft world. You should even use JavaScript for creating CRUD operation on Windows Azure Mobile Services (I won’t say here about missing test system and source code tracking hereJ). Next significant point: all Microsoft skills and power is shifted to mobile world: html5, JavaScript and of course mobile platforms.

Secondly, mostly interesting question is about Silverlight future.

After this event I have a following opinion. Steven Sinofsky completely kills Silverlight as a Microsoft trend. However, don’t start to move all your application out of this. There is really good feature for this technology at business sector (especially at conservative business, such as insurance/financing/bank sectors). Here I’m pretty sure Silverlight can be a good choice for creating Rich Internet application.

Last one, but not boring part. Microsoft features.

There are only few words: web + Azure! New Microsoft ASP.NET MVC 4 is absolutely fantastic framework. Have a look at the video from Scott Guthrie “A Look at ASP.NET MVC 4”

A Look at ASP.NET MVC 4

BTW: after session I had a small conversation with him about web and new ASP.NET Web API. I’d like to say: he is really energetic person which can energetically charge an interlocutor. After this few minutes I was full of energy and felt as a Superman J
Next huge topic was Microsoft Azure, awesome platform!

There is a video from Nick Harris about new features here:

Devices + Cloud: Using Windows Azure with Windows Phone, iOS, Android, …

At the end, I would like to say, that TechDays 2012 was a good event, thank you everybody who helped to organize all of this! I really enjoy it and hope it wasn’t my last such a big TechDays.

What has been done during 2011 year?

This year is almost finished and I’d like to summarize what has been done, what I should improve. New Year’s good time to know: where you are on the road map, add new goal to life and analyse productivity.

If you want to do something grandiose in one of the beautiful days,

remember – this day is today!

(c) George Lucas

This list I had in the beginning of 2011 year (of course without my private goals which all have been done) and what has been done:

  1. Change a job.Success

    I have been working for 3 years for one company in Ukraine. It was my first job, I grown there from junior-developer to senior developer. I met a lot of interesting people; I worked with customers which gave me knowledge in variety areas. However, on someday I realize that our ways are different, that I need something more in business and technical knowledge. For this I decided to push myself a little bit. My new company was in the Donetsk, Ukraine too. I worked there around half a year as a head of .NET department but on not good productL. (Why I left that company on the next item).

  2. Immigration.Success

    In a university I made a decision to work (or live) abroad. In 2011 year I had decided to do it. As a result I’m working with high-motivated professionals for fantastic company in Antwerp city, Belgium.

  3. Visit one of the solid conferences.Success

    On November 14-15, 2011 I’ve visited a SQL Server Days 2011. If you want to know more please read this post about first day and this one about second day in a conference.

  4. Pass 70-564 and become a MCPD ASP.NET developer.Success
  5. Read 10 books.Success

    At the end of the year I read around 15-20 maybe (I calculated only technical books). So this item was underestimated. As a result on the next year I put 20 (I don’t want to improve this now because I need time for other things). Last book were about project management and Agile You can find some of them on my LinkedIn profile. And I’m planning to move on that direction. I feel that I need more knowledge on business too (Maybe for this I’ll graduate some business college or university here in Belgium. I already have one which interesting for me. It’s EHSAL Management School. So if you know something or ever graduated that one please live a comment!)

  6. Pass 70-523: upgrade MCPD ASP.NET 3.5 to MCPD ASP.NET 4.0.Fail

    It was one of things which I decided not to do and really regret about. Last year all my projects were Silverlight. I’m feeling shortage of experience on this area. However I’m not sure that I put it to the next year’s list.

  7. English: pass IELTS.Fail

    I’m absolutely sure that this one is the biggest my fault. I definitely need to improve my English. I decided not to take this but I’m 100% sure that “pass IELTS” is one of the strong motivated factors. This item is absolutely MUST HAVE on my next year’s list.

  8. Create a first Windows Phone 7 application.Fail

    I decided to move on this direction. I really like this OS and Metro style. I’m working around 3 month on my application. Now I think it’s ready on 60%-70%. I still should implement good design and publish it on marketplace. Hope, I can do it on February.

  9. Create a blog with N-thousands visitors.Success

    At the end of the year I’ve exceeded this item on 155%. However, now I think it’s my mistake. I shouldn’t evaluate blog by “visitor” measure. I need to think about this item on next year because I don’t satisfy with “post count” measure too.

In a conclusion I would like to maintain that 2011 year was really productive for me with a lot of fun and success. I hope next one would be ever more interesting and productive. Also I’d like to say thank you everyone how was on this year with me!

I hope you all enjoyed Christmas, and I wish you all a happy and productive 2012 year!