
Back to Blog index.
It's time to thank you for the year at end, and wish everybody Happy New Year 2010! As briefly mentioned last week, remember to update the URL of this blog if you are reading it through RSS/XML. The new URL is:
http://www.saunalahti.fi/janij/blog/2010.xml
The URL will start to work in a couple of days. Until then, stay warm, and see you again next year!
If you are interested in the latest MSDN downloads to play with, and you are using Twitter, then there's a new stream of tweets that you might interested in. The MSDNDownloads twitter account is something to follow on.
You can also see the tweets as an RSS feed here:
http://twitter.com/statuses/user_timeline/44571989.rss
This way, you never miss a new download anymore!
Some quick reading for the holiday season: if you are interested in Microsoft's Expression Studio 3, then check out the ezine (web magazine) sponsored by Microsoft UK: "Expression Studio 3: The Ultimate Guide". This 28 page magazine, delivered with Flash is nice, light reading.
Enjoy!
Merry Christmas to everybody! Today's post will be short one, but the happier. The holiday season is a great time to chill out, and maybe play and old game or two. My personal favorites are those ol' games from the Commodore 64 era, and thus a new version of M.U.L.E. is a welcome addition to the web.
Also, you might wish to check out the games catalog of Good Old Games, you will surely find something to play from there.
Developer.com (now with a new owner, by the way) has recently published my latest article about using Windows 7 jump lists.
The article is titled "Creating Windows 7 Jump Lists With The API Code Pack and Visual Studio 2008" and shows how you can use the free Windows API Code Pack to write applications for Windows 7 with Visual Studio 2008.
I hope you like it!
As the year is soon drawing to an end, a friednly reminder is in order: if you are reading this blog through the RSS feed, your feedreader is probably using an URL similar to this:
http://www.saunalahti.fi/janij/blog/2009.xml
As you can see, the RSS feed ends with the number of the current year. Next year, the URL should end with "2010.xml", so remember to change the URL accordingly to continue reading this blog.
Thank you! (At this writing, the new URL does not yet exist, but don't worry, it will in a couple of weeks.)
Even if you have been using Visual Studio for a while, you might not have run into a Visual Studio feature called T4. T4, or TTTT, actually stands for Text Template Transformation Toolkit. But what is this toolkit, and what is it used for?
Let's take a concrete example from ASP.NET MVC. If you are creating a new view with the Add View command, Visual Studio creates a new .aspx page with ready-made HTML code. But where does this code come from? It comes from file-based templates.
Where do these templates live? By default, Visual Studio installation creates a folder called "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE", which contains numerous subfolders for different template types, including those in the New Project/New Item dialog boxes. For ASP.NET MVC templates, there's a folder called "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView". This folder in turn contains template files with the .tt extension.
These files contain simple scripts with the T4 is able to process, and then output text data based on the results of running the scripts, similar to processing the <% and %> tags in .aspx files.
Sounds interesting, right? The good thing is that you can even utilize this engine in your own projects. For more details, see the MSDN documentation.
If you are developing smaller applications that utilize an SQL Server database, chances are the you need to take part or at least give advice to your customers on how to administer and maintain the database.
SQL Server is a dependable database, and for the most time, you don't need to maintain your database much. However, from time to time, problems might surface, and if this happens, your customer might contact you about what to do next.
Today's tip is an SQL Server command to check database consistency. This can be done with the command DBCC CHECKDB. This command "checks the logical and physical integrity of all the objects in the specified database" and gives you a simple report of its findings.
Running this command periodically, say once every quarter, to check if everything is still okay. At best, this command can give you hints that something might go wrong in the future.
Sometimes, you wander into a new area in the .NET framework that you might not know like the back of your hand. And if you are beginning to learn the Microsoft framework, then you might want to find a simple Visual Studio project, that would display a simple demo of a given feature, and then allow you to work on your own from there.
Enter the All-In-One Code Framework, i.e. CodeFx (CFX), which is a CodePlex project. This means that the CodeFx project (actually, a Visual Studio solution) that contains currently over 200 different technology demos in C# and C++.
If you are in ready-made sample applications on many different .NET technologies, then All-In-One Code Framework is a good place to start. Remember that the ‘net is also full of code examples, but they tend to be isolated examples. If possible, CodeFx examples on the other hand try to build a set of demos that complement each other.
The latest issue of the Finnish Prosessori magazine contains my latest Windows developer article, this time about Windows Mobile 6.5. The article is titled "Windows-kännykät ymmärtämään kosketusta". There's a small typo in the author's name, it says Jari instead of Jani, but nonetheless, the article itself should be fine.
Happy reading, and remember to give feedback! Thank you!
MSDN's Channel 9 contains already lots of material about the forthcoming Visual Studio 2010 and .NET Framework 4.
Now, there's a new site dedicated to this information. Be sure to check it out!
PS. Happy birthday, Finland!
Another ASP.NET MVC tip. If you are using extension methods in your controller action methods (I find extension methods useful from time to time, even though they can be thought of as being "code smells"), you might also wish to use them in your view pages (the .aspx files in the Views folder).
Personally, I usually write my classes and methods as being internal if they are designed only to be used from the same application/assembly. For instance, the code might something like this:
internal static class Extensions
{
internal static string ToShortTimeValue(this TimeSpan time)
{
return time.Hours + ":" +
string.Format("{0:00}", time.Minutes);
}
}
However, if you are writing ASP.NET MVC applications and try to use these classes in your view pages, there's a catch. Try it, and you will get errors like this:
c:\Documents\Visual Studio 2008\Projects\MvcApplication1\Views\Customers\Detail.aspx(32,33): error CS1061: 'System.TimeSpan' does not contain a definition for 'ToShortTimeValue' and no extension method 'ToShortTimeValue' accepting a first argument of type 'System.TimeSpan' could be found (are you missing a using directive or an assembly reference?) c:\Documents\Visual Studio 2008\Projects\MvcApplication1\Views\Customers\Detail.aspx(36,31): error CS1061: 'System.TimeSpan' does not contain a definition for 'ToShortTimeValue' and no extension method 'ToShortTimeValue' accepting a first argument of type 'System.TimeSpan' could be found (are you missing a using directive or an assembly reference?)
Why does this happen? The error message gives you a clue, as you will have to refresh in your mind the way ASP.NET applications are compiled. If you are using MVC, you might think that all code goes into a single assembly, but in the case of view pages, this is not true. Instead, the view page code goes into its own assembly, usually located somewhere under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root. Because the view pages are in a different assembly, the "internal" access modifier will not be visible enough to the view page assembly.
Of course, the remedy is very simple. Simply change the extension class and method(s) be public:
public static class Extensions
{
public static string ToShortTimeValue(this TimeSpan time)
{
return time.Hours + ":" +
string.Format("{0:00}", time.Minutes);
}
}
Good luck!
Happy December! Recently, I've created multiple application with ASP.NET MVC, and overall I really like the new technology. Of course, no technology isn't without its quirks, and ASP.NET MVC is not an exception. Yesterday, I ran into an interesting issue that I hadn't noticed before. When creating a view from a controller action method (right-click and then choose Add View), I got the following error:
Template Processing resulted in 2 Errors --------------------------- c:\Temp\bqqraxkg.0.cs(4,18) : error CS0234: Compiling transformation: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) c:\Temp\bqqraxkg.0.cs(5,18) : error CS0234: Compiling transformation: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
This seemed only to happen when I added a Details type of view. Although I tried multiple times, this didn't help. Then, I though that maybe there were too many files in the C:\Temp directory. Clearing this directory solved the problem. So, if you run into a similar problem, check where your system environment variable %TEMP% points to, and delete all files from that directory. Then try again.
Hope this helps!
› Blog Archive