howto (RSS)

tips and tricks and howtos.

Free Expression Design and Expression Blend training from Lynda.com

Lynda.com is offering their Expression Blend and Expression Design trainings for free for everyone. Both trainings are 6 hours long.

Expression Blend

http://movielibrary.lynda.com/html/modPage.asp?ID=384 - Getting started with Expression Blend.

In Getting Started with Expression Blend , Lee Brimelow covers all the basics that every designer and developer of WPF and Silverlight content needs to know. He starts with an overview of how Expression Blend fits into WPF and Silverlight workflows, then guides viewers through the process of creating and manipulating objects, building timeline-based animations, and exporting compositions into XMAL for use in Visual Studio.


http://movielibrary.lynda.com/html/modPage.asp?ID=359  - Expression Blend Beta Preview.

Expression Blend is a new interactive authoring tool from Microsoft that is available for free as a public beta. Instructor Lee Brimelow explores all of the application's features and capabilities, from the user interface panels to creating and importing assets. He also covers integrating 3D content, using WPF text controls, layout controls, and user input controls, and creating animated effects. Expression Blend Beta Preview gives a comprehensive insider look at the new version of Expression Blend before it hits the shelves.

 

Expression Design

 http://movielibrary.lynda.com/html/modPage.asp?ID=339 - Getting Started with Expression Design.

From basic vector-based drawings to professional three-dimensional graphics built with Live Effects, Ted LoCascio covers the full range of possibilities in Getting Started with Expression Design. He starts by explaining Expression Design's interface and how to work with documents, then moves on to cover working with objects and applying fills, strokes, and effects for best results. Exercise files accompany this training.

Ethereal Packet sniffing tutorials...

While browsing the net I found a nice set of tutorials called Packet School 101 on Chris Sander's blog. A developer type like me, who needs to take a look at packet sniffs from time to time this is a very usefull set of articles.

Reenabling Fast-User Switching and the Welcome Screen on Windows XP

I had an XP machine in a domain and I needed to test something with Fast-User Switching and the Welcome Screen. The steps below are the fruit of an hour worth of swearing and sweating :)

  • First is to remove the machine from the domain. It has to be in a Workgroup.
  • Next go to the Control Panel and Administrative Services, select Services and Enable Fast User Switching Service.
  • The again Control Panel and User Accounts and select Change the way users log on or off.
  • You may receive a message about Offline Files and that it needs to be turned off. Turn it off.
  • You check both the Welcome Screen and the Fast User Switching checkboxes.

Nothing seems to be difficult, I spent 46 minutes with second step (figuring out that I need to start the service) and 4 minutes with the other steps.

The 3 key windows shutdown trick

As if they are reading my mind over lifehacker.com. I really wanted some way to quickly put my computer to sleep and were looking for a small utility to do this for me. Another small icon sitting on my already overcrowded tray, but it turns out there is a simpler way to put your computer to sleep. The winner tip of "your best windows tip" contest is Mr. Fusion's three-key shutdown tip. What you need to do is for quickly stopping your computer is to press:

Windows key, U , U again.

I quickly figured out that I can also do standby by pressing:

Windows key, U, S.

and for Restart:

Windows key, U, R.

Lifehacker rocks!!!

How to set up Microsoft Symbol Server

Symbol server is important if you have large projects on the Windows platform within a large organization and your process involves daily/nightly builds. Then you have to distribute really large number of binary files impacting your network traffic. Instead of copying every single one of your symbols you can set up a symbol server, where the symbol files are distributed on demand, this way you can easily save gigs of network bandwidth and storage.

Setting up a Symbol Server.

How to Kernel debugg a virtual pc image with windbg.

Here is a really quick howto if you want to kernel debug a virtual pc image on your machine.

  • on virtual pc modify the boot.ini file. Add the following: 

    /DEBUG /DEBUGPORT=COM the number of the COM port that you want to use for debugging /BAUDRATE=115200

Boot.ini then will look like this:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetect
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise" /fastdetect/DEBUG /DEBUGPORT=COM2/BAUDRATE=115200

  • Configure the serial port for virtual PC

    Virtual PC 2004
  • Start Virtual PC 2004.
    Click the virtual machine that you want to configure, and then click Settings.
  • In the Setting list, click the serial port that you want to configure, click Physical serial port, and then click to clear the Wait for modem command to open port check box if it is selected.
  • Click Named pipe, and then type \\.\pipe\ name that you want to assign to the named pipe in the Named pipe box. For example, type \\.\pipe\com2 .
  • Click OK. 


Virtual Server 2005

  • Start the Virtual Server Administration Website program. To do this, click Start, point to All Programs, point to Microsoft Virtual Server, and then click Virtual Server Administration Website.
  • Under Virtual Machines, point to Configure, and then click the virtual machine that you want to modify.
  • Click the COM ports link.
  • Under the serial port that you want to configure for debugging, click Physical computer serial port, and then click to clear the Wait for modem command to open port check box.
  • Click Named pipe, and then type \\.\pipe\ name that you want to assign to the named pipe in the Named pipe box. For example, type \\.\pipe\com2 .
  • Click OK.
     
  • start windbg
    Windbg -k com:port=\\.\pipe\ pipe name ,pipe,resets=0,reconnect


Source:
How to debug the Virtual Server service on a computer that is running Virtual Server 2005 or Virtual PC 2004, part 1 of 2

How to single step in IL code

Under VS debugger, you can single-step the code at native level, but not at IL level. To achieve single-stepping at IL level, you need to do the following trick (works with C# and VB apps, doesn't with most VC++ apps):

  • build C#/VB app, debug version;
  • ildasm it with /source option (original source lines will be put into disassembly as comments);
  • ilasm the disassembly with /debug option (new EXE/DLL and PDB will bind the IL code to the disassembly's text rather than to the original C#/VB text, but you have the original C#/VB text embedded in the disassembly);
  • run new executable under VS debugger.

This is posted by Serge Lidin and the original post can be found here:
http://discuss.develop.com/archives/wa.exe?A2=ind0408b&L=advanced-dotnet&T=0&F=&S=&P=5566

Howto troubleshoot serialization problems

 

If you see an exception with an ugly message like this popping out from your XmlSerialization code:

 

System.IO.FileNotFoundException: File or assembly name 5h6ie2ca.dll, or one of its dependencies, was not found.

File name: "smgytoa1.dll"

 

That means that dynamic compilation fails during the serialization or deserialization operation. Then you need to do the following. Open your machine.config file (mine is located here c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config) and modify it like this:

    <system.diagnostics>
         <switches>
            <add name="XmlSerialization.Compilation" value="4"/>
         </switches>
    </system.diagnostics>


This way the files involved with the dynamic files will be kept in your %TEMP% folder and you can inspect them after the error. After receiving the erro mentioned before I see the following files in my %TEMP% folder:

 

smgytoa1.pdb - looks like some sort of debug symbol.

smgytoa1.out - this is the file you should look at if you want to see what errors were produced during the compilation.

smgytoa1.err  - this file looks empty. No idea why it is there.

smgytoa1.cmdline - the command line used for compilation.

smgytoa1.0.cs - the source file generated. It will be referenced in the .out file.

 

Created with Microsoft Office OneNote 2003
One place for all your notes

A word for Windbg

Introduction to windbg for both managed and unmanaged debugging

A word for WinDbg - short introduction to unmanaged debugging.
http://mtaulty.com/blog/archive/2004/08/03/608.aspx

 

A word for WinDbg (2) - short introduction to managed debugging.
http://mtaulty.com/blog/archive/2004/08/03/609.aspx

 

Created with Microsoft Office OneNote 2003
One place for all your notes

How to detect what version of .NET Framework installed

 

Let's say you are creating a deployment package for your application with Visual Studio.NET and you would like to specify what version of the .NET Framework needs to be installed on the target machine for your application. First have a look at this knowledge base article:

 

How to detect the version of the .NET Framework that is installed in a deployment package in Visual Studio .NET

http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;315291

 

The gist of he kb article above is that this is done by checking creating launch condition in your deployment project and checking of the existence of certain registry keys and their values.

 

For the .NET Framework 1.0:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.0

For the .NET Framework 1.1:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v1.1

 

For .NETv1.0 the Name is 3705 and the registry value "3321-3705"
For .NETv1.1 the Name is 4322 and the registry value "3706-4322"
For .NETv2.0 Beta1 the Name is 40607 and the registry value "40607-40607"

Please, not that only the first two version is official, the last one is what I found in the registry of my computer.

 

Created with Microsoft Office OneNote 2003
One place for all your notes

Creating a union like class in C#

 

I was looking for solution how to retreive bytes of a long and stuff like this. Similar to the byte manipulation what you would do in C using unions. Today I just come across the FieldOffset attribute and created this class.

 

using System;

using System.Runtime.InteropServices;

 

 

[StructLayout(LayoutKind.Explicit)]

class UnionLikeClass

{

// 64 bit

[FieldOffset(0)]

public System.UInt64 uint64;

 

// 32 bit

[FieldOffset(0)]

public System.UInt32 uint32_0;

[FieldOffset(4)]

public System.UInt32 uint32_1;

 

 

// 16bit

[FieldOffset(0)]

public System.UInt16 uint16_0;

[FieldOffset(2)]

public System.UInt16 uint16_1;

[FieldOffset(4)]

public System.UInt16 uint16_2;

[FieldOffset(6)]

public System.UInt16 uint16_3;

 

// 8bit

[FieldOffset(0)]

public System.Byte byte_0;

[FieldOffset(1)]

public System.Byte byte_1;

[FieldOffset(2)]

public System.Byte byte_2;

[FieldOffset(3)]

public System.Byte byte_3;

[FieldOffset(4)]

public System.Byte byte_4;

[FieldOffset(5)]

public System.Byte byte_5;

[FieldOffset(6)]

public System.Byte byte_6;

[FieldOffset(7)]

public System.Byte byte_7;

}

 

The class gives you the abilitity to quickly retreive the bytes from a long or an integer.

 

Created with Microsoft Office OneNote 2003
One place for all your notes

IDesignerHost nightmare....

Spent ages to understand how to host a winform designer and generate code and xml out of it. How to load it back. It was a painfull and long week and at the end it turns out that there is already a kb article demonstrating this:

INFO: Code Sample That Demonstrates How to Create a Custom Form Designer by Using Visual C# .NET
http://support.microsoft.com/?id=813808

 Doh!

Adding some keywords: ComponentModel.Design, ComponentModel.Design.Serialization, DesignerHost, IExtenderProvider, IEventBindingService, ISite, IDictionaryService, IDesignerSerializationManager, DesignerLoader, ITypeResolutionService, ITypeDescriptorFilterService, IToolboxService

Where is the GAC?

It turns out that there is no single place for this... you can find the list of files like this:

  • gacutil.exe /l from command util
    lists the files registered in GAC.
  • c:\windows\assembly
    this invokes the Assembly Fusion Cache Viewer (shfusion.dll). I could really use right click enabled ngen from here...
  • Control Panel | Administrative Tools | Microsoft .NET Framework Configuration, then Assembly Cache in the tree.
  • c:\Windows\Assembly\GAC\ from command prompt only.
  • %SYSTEMROOT%\assembly\gac\
    This way you can get past the shfusion.dll. Type it in the run window and you can navigate the GAC from the Shell Explorer....


Path.GetTempFile()

I just found this cool method couple of days ago and I think it is just really cool, here is a short description what it does

public static string GetTempFileName();

Returns a unique temporary file name and creates a zero-byte file by that name on disk.