Monday, May 17, 2010

Free PowerCommands 10.0 – for Visual Studio 2010

Every developer using VS must have: PowerCommands 10.0

Here is the list of commands:

Enable/Disable PowerCommands in Options dialog
This feature allows you to select which commands to enable in the Visual Studio IDE. Point to the Tools menu, then click Options. Expand the PowerCommands options, then click Commands. Check the commands you would like to enable.
Note: All power commands are initially defaulted Enabled.

Format document on save / Remove and Sort Usings on save
The Format document on save option formats the tabs, spaces, and so on of the document being saved. It is equivalent to pointing to the Edit menu, clicking Advanced, and then clicking Format Document. The Remove and sort usings option removes unused using statements and sorts the remaining using statements in the document being saved.
Note: The Remove and sort usings option is only available for C# documents.
Note: Format document on save and Remove and sort usings both are initially defaulted OFF.

Clear All Panes
This command clears all output panes. It can be executed from the button on the toolbar of the Output window.

Copy Path (winmike: one of my favorite commands!!!)
This command copies the full path of the currently selected item to the clipboard. It can be executed by right-clicking one of these nodes in the Solution Explorer:
The solution node; A project node; Any project item node; Any folder.

Email CodeSnippet
To email the lines of text you select in the code editor, right-click anywhere in the editor and then click Email CodeSnippet.

Insert Guid Attribute
This command adds a Guid attribute to a selected class. From the code editor, right-click anywhere within the class definition, then click Insert Guid Attribute.

Show All Files
This command shows the hidden files in all projects displayed in the Solution Explorer when the solution node is selected. It enhances the Show All Files button, which normally shows only the hidden files in the selected project node.

Undo Close
This command reopens a closed document , returning the cursor to its last position. To reopen the most recently closed document, point to the Edit menu, then click Undo Close. Alternately, you can use the CtrlShiftZ shortcut.
To reopen any other recently closed document, point to the View menu, click Other Windows, and then click Undo Close Window. The Undo Close window appears, typically next to the Output window. Double-click any document in the list to reopen it.

Collapse Projects
This command collapses a project or projects in the Solution Explorer starting from the root selected node. Collapsing a project can increase the readability of the solution. This command can be executed from three different places: solution, solution folders and project nodes respectively.

Copy Class
This command copies a selected class entire content to the clipboard, renaming the class. This command is normally followed by a Paste Class command, which renames the class to avoid a compilation error. It can be executed from a single project item or a project item with dependent sub items.

Paste Class
This command pastes a class entire content from the clipboard, renaming the class to avoid a compilation error. This command is normally preceded by a Copy Class command. It can be executed from a project or folder node.

Copy References
This command copies a reference or set of references to the clipboard. It can be executed from the references node, a single reference node or set of reference nodes.

Paste References
This command pastes a reference or set of references from the clipboard. It can be executed from different places depending on the type of project. For CSharp projects it can be executed from the references node. For Visual Basic and Website projects it can be executed from the project node.

Copy As Project Reference
This command copies a project as a project reference to the clipboard. It can be executed from a project node.

Edit Project File
This command opens the MSBuild project file for a selected project inside Visual Studio. It combines the existing Unload Project and Edit Project commands.

Open Containing Folder
This command opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node

Open Command Prompt
This command opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively.

Unload Projects
This command unloads all projects in a solution. This can be useful in MSBuild scenarios when multiple projects are being edited. This command can be executed from the solution node.

Reload Projects
This command reloads all unloaded projects in a solution. It can be executed from the solution node.

Remove and Sort Usings
This command removes and sort using statements for all classes given a project. It is useful, for example, in removing or organizing the using statements generated by a wizard. This command can be executed from a solution node or a single project node.

Extract Constant
This command creates a constant definition statement for a selected text. Extracting a constant effectively names a literal value, which can improve readability. This command can be executed from the code editor by right-clicking selected text.

Clear Recent File List
This command clears the Visual Studio recent file list. The Clear Recent File List command brings up a Clear File dialog which allows any or all recent files to be selected.

Clear Recent Project List
This command clears the Visual Studio recent project list. The Clear Recent Project List command brings up a Clear File dialog which allows any or all recent projects to be selected.

Transform Templates
This command executes a custom tool with associated text templates items. It can be executed from a DSL project node or a DSL folder node.

Close All
This command closes all documents. It can be executed from a document tab.

 

Enjoy!

Monday, May 10, 2010

Internet Explorer 9 Platform Preview

05/05/2010 – update for IE9 Platform Review: in fact, new IE.

Download it here, the release notes (incl. What’s new) – here.

1. Open an URL with IE9 use menu Page –> Open:

image

2. Use built-in developer tool:

image

3. Switch to different IE modes:

image

Enjoy!

Thursday, April 22, 2010

Virtualized development environment for Windows Server 2008 R2

It went too good: starting with free-of-charge Microsoft (c) Virtual PC/Microsoft (c) Virtual Server each serious developer for Microsoft (c) Windows had similar workstation configuration: - client OS (WinXP/Vista/Win7) - development environment (VS05/08/10) - Virtual PC or Virtual Server - set of VHD's presenting virtual machines for development and developer tests

Especially "Undo Disks" did the usage of virtualization software so sweet: just drop the changes of the last session and start over without any needs to reinstall experimental machine.

This was very suitable for server software development since until incl. Windows Server 2008 there was always a 32-bit (x86) version of the server OS. Thus, everybody could emulate a server on his developer machine.

Starting with Windows Server 2008 R2 there are no more 32-bit versions of the server OS from Microsoft: x64 and IA64 only. Even more: on Apr. 4th Microsoft announced end of support for IA64 architecture(i.e. Itanium processor family) and encourages the current IA64 customers to move towards x64.

That means, the only hardware platform any Windows server software developer has to care about is x64.

Looks good, but... neither Virtual PC nor Virtual Server do support 64-bit guests OS. The only way is to use virtual machines with OS instances to develop is to use virtualization software supporting 64-bit (x64) guests OS. For example, Hyper-V - known since Windows Server 2008.

Fine, let us move from Virtual PC to Hyper-V. Not so quickly: there's actually no Hyper-V for client OS: neither Vista nor Win7. The only virtualization software from Microsoft for Win7 is Windows XP mode - AKA Virtual PC. With the same limitation as before: no 64-bit guests OS.

Finally, the developer should now (until the situation changes) select one of possible configurations:

  1. Two physical boxes solution:

    -Box1: Client OS (WinXp/Vista/Win7) + development environment

    -Box2: Windows Sever 2008 R2 + Hyper-V + VHDs as virtual machines for development.

  2. Single physical box solution - Box1: Server OS (Windows Server 2008 R2) + development environment + Hyper-V + VHDs as virtual machines for development.
  3. Single physical box solution using 64-bit client OS and VMWare Workstation as virtualization software... (I didn't try it, unfortunately).

Until no Microsoft virtualization software supporting 64-bit guests OS are in place, we have to accept the constraints...

Enjoy!

Friday, March 26, 2010

The location of the file or directory […] is not trusted.

Hard work over last three days using laptop, today I’ve copied the project files onto the developer box, loaded the project in VS and tried to test. The test project failed with following message:

The location of the file or directory [<here comes the project path/project coniuration file>.config] is not trusted.

vserror

The problem is, the config file for the project is copied from other computer.

To solve the problem:

1. Go to the folder containing the config file and view the file properties:

beforeunblock

2. Click “Unblock” and review the properties:
afterunblock

3. Restart the project – and enjoy!

(This post is published with Windows Live Writer)

Thursday, March 25, 2010

The type [ ] provided as the Service attribute value in the ServiceHost directive could not be found.

We have a list of WCF services hosted in IIS, implemented in numerous assemblies.
Testing all the services after each deployment we encounter from time to time the error:


The type [ ] provided as the Service attribute value in the ServiceHost directive could not be found.


Unfortunately, there's no much more info, why the referenced type cannot be found. First, we wrote some test code (actually console application to scan the assemblies and implemented service types). This solution has its limits: starting with differences in security context etc.

Surfing the Web, we found following approach to investigate the problem.

Slightly extending the idea, we created the ASPX page, helping us to test deployed assemblies and implemented as services types.

The page collects on start information about all installed in the virtual directory assemblies (optionally - recursively or just the /bin folder) and lists automatically all implemented types after one assembly is selected.


Here's the screenshot for succeeded call:
clip_image001
... and this one - on failure:
clip_image002
The page source:


------------------START
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Runtime.Remoting" %>
<script runat="server">
    protected override void  OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            initializeAssemblyList();
        }
        base.OnLoad(e);
    }
    private void initializeAssemblyList()
    {
        string[] files;
        DropDownListAssembly.Items.Clear();
        if (!CheckBoxBinFolderOnly.Checked)
        {
            files = System.IO.Directory.GetFiles(Server.MapPath(""), "*.dll", System.IO.SearchOption.AllDirectories);
        }
        else
        {
            files = System.IO.Directory.GetFiles(Server.MapPath("bin"), "*.dll");
        }
        foreach (string file in files)
        {
            DropDownListAssembly.Items.Add(file);
        }
        initializeTypeList("");
    }
    private void initializeTypeList(string assemblyFullName)
    {
        DropDownListType.Items.Clear();
        if (!string.IsNullOrEmpty(assemblyFullName))
        {
            foreach (Type type in System.Reflection.Assembly.LoadFile(assemblyFullName).GetTypes())
            {
                DropDownListType.Items.Add(type.FullName);
            }
        }
    }
    protected void ButtonTest_Click(object sender, EventArgs e)
    {
        try
        {
            TextBoxResult.Text = "";
            ObjectHandle objHandle = Activator.CreateInstance(
                TextBoxAssembly.Text,
                TextBoxType.Text
                );
            TextBoxResult.Text =
            string.Format("Successfully loaded {0} from {1}.",
                objHandle.Unwrap(),
                TextBoxAssembly.Text);
        }
        catch (Exception ex)
        {
            TextBoxResult.Text = ex.Message + "\r\n" + ex.StackTrace;
        }
    }
    protected void DropDownListAssembly_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            TextBoxResult.Text = "";
            string assemblyFullName = DropDownListAssembly.SelectedValue;
            string[] chunks = assemblyFullName.Split('\\');
            string assemblyName = chunks[chunks.Length - 1];
            assemblyName = assemblyName.Replace(".dll", "");
            TextBoxAssembly.Text = assemblyName;
            TextBoxType.Text = "";
            initializeTypeList(assemblyFullName);
        }
        catch (Exception ex)
        {
            TextBoxResult.Text = ex.Message + "\r\n" + ex.StackTrace;
        }       
    }
    protected void DropDownListType_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBoxResult.Text = "";
        string typeName = DropDownListType.SelectedValue;
        TextBoxType.Text = typeName;
    }
    protected void CheckBoxBinFolderOnly_CheckedChanged(object sender, EventArgs e)
    {
        try
        {
            initializeAssemblyList();
        }
        catch (Exception ex)
        {
            TextBoxResult.Text = ex.Message + "\r\n" + ex.StackTrace;
        }             
    }
</script>
<% %>
<html>
<head>
<style type="text/css" media="screen">
    body {font-family: @Arial Unicode MS; font-size: x-small; background-color:silver;}
    span {font-family: @Arial Unicode MS; font-size:x-small}  
    .button {font-family: @Arial Unicode MS; font-size: x-small;}
    .textbox { width: 700 px;font-family: @Arial Unicode MS; font-size: x-small;}
    .dropdown { width: 700 px; font-family: @Arial Unicode MS; font-size: x-small;}
    .textboxmulti { width: 700 px; height: 400 px;font-family: @Arial Unicode MS; font-size: x-small }
    .validator { width: 700 px;font-family: @Arial Unicode MS; font-size: x-small; color: Red;}
</style>
</head>
<form id="form1" runat="server">
<div><asp:Label ID="LabelAssembly"  AssociatedControlID="TextBoxAssembly" runat="server" Text="Enter Assembly Name:"></asp:Label></div>
<div>
    <asp:requiredfieldvalidator runat="server"
        errormessage="Assembly name missing!" ControlToValidate="TextBoxAssembly"
        Display="Dynamic" SetFocusOnError="True" CssClass="validator"></asp:requiredfieldvalidator></div>
<div><asp:TextBox ID="TextBoxAssembly" runat="server" CssClass="textbox"></asp:TextBox></div>
<div><asp:Label ID="LabelSelectAssembly"  AssociatedControlID="DropDownListAssembly" runat="server" Text="...or select from list:"></asp:Label></div>
<div><asp:checkbox ID="CheckBoxBinFolderOnly" Text="'bin' folder only"
        runat="server" AutoPostBack="True"
        oncheckedchanged="CheckBoxBinFolderOnly_CheckedChanged"></asp:checkbox>
</div>
<div>   
    <asp:dropdownlist runat="server" ID="DropDownListAssembly"
        onselectedindexchanged="DropDownListAssembly_SelectedIndexChanged"
        AutoPostBack="True" CssClass="dropdown">
        </asp:dropdownlist>
    </div>
<div><asp:Label ID="LabelType"  AssociatedControlID="TextBoxType" runat="server" Text="Enter Fulltypename:"></asp:Label></div>
<div>
    <asp:requiredfieldvalidator runat="server"
        errormessage="Type name missing!" ControlToValidate="TextBoxType"
        Display="Dynamic" SetFocusOnError="True" CssClass="validator"></asp:requiredfieldvalidator></div>
<asp:TextBox ID="TextBoxType" runat="server" CssClass="textbox"></asp:TextBox></div>
<div><asp:Label ID="LabelSelectType"  AssociatedControlID="DropDownListType" runat="server" Text="...or select from list:"></asp:Label></div>
<div>
    <asp:dropdownlist runat="server" ID="DropDownListType"
        onselectedindexchanged="DropDownListType_SelectedIndexChanged"
        AutoPostBack="True" CssClass="dropdown">
        </asp:dropdownlist>
    </div>
<div><asp:Button ID="ButtonTest" runat="server" Text="Test load type" onclick="ButtonTest_Click" /></div>
<div><asp:Label ID="LabelResult"  AssociatedControlID="TextBoxResult" runat="server" Text="Result:"></asp:Label></div>
<div>
    <asp:TextBox ID="TextBoxResult" runat="server" ReadOnly="True"
        TextMode="MultiLine" CssClass="textboxmulti"></asp:TextBox>
</div>
</form>
</html>
------------------END

1. Copy the text.

2. Save in an ASPX file (for example, TestService.aspx).

3. Put the file in Virtual Directory hosting your Services.
clip_image004

4. Call the page to ensure, the assemblies and the servicing types can be loaded.

Enjoy!

(This post is created with Windows Live Writer)

Friday, January 29, 2010

Windows Server 2008 R2 Core activation by phone

Here is a very good manual, how to activate Windows Server 2008 R2 Core by phone.
Short summary:
  1. Enter product key: Cscript.exe %systemroot%\system32\slmgr.vbs -ipk
  2. Get installation ID: Cscript.exe %systemroot%\system32\slmgr.vbs -dti
  3. Get phone number to receive the activation ID: notepad %systemroot%\system32\sppui.inf
  4. There' a bug in the original article - the filename to get the phone number is wrong
  5. Choose and call the phone number, follow instructions, receive activation ID
  6. Write down the activation ID received by phone (ideally write it directly to a notepad window to copy and paste then for product activation
  7. Activate product using: Cscript.exe %systemroot%\system32\slmgr.vbs –atp
  8. Verify product activation: Cscript.exe %systemroot%\system32\slmgr.vbs –dlv
  9. Enjoy!

Friday, January 15, 2010

Crash dump file missing with Windows 7

Yes, even Windows 7 can crash. And one may want to know why. Looking for .dmp file you may be very surprised: the .dmp file won't be saved on the local disk.

It is not a bug - it is the new feature in Windows 7.

After hours spent to locate the reason, found following article @ OSR: one of my favorite sources regarding Windows kernel.

Shortly:
"By setting the \HKLM\System\CCS\Control\CrashControl\AlwaysKeepMemoryDump DWORD value to 1 you will guarantee that you will always have a crash dump file after crashing the system."

Set the registry key an enjoy!



Friday, January 08, 2010

wsdl and blanks in file pathnames

Using wsdl utility (as for WIndows SDK 6.0A) you may encounter following error:

Error: Could not find a part of the path 'd:\projects\my%20project\xsd\type1\Adresses.xsd'.

This is because your project filepath contains blanks:

"d:\projects\my project\xsd"

Copy files to another, MS DOS - 8.3 - conform location and retry (for example,

"d:\projects\myprj\xsd"

).
You will see it works now.
Enjoy!

Wednesday, January 06, 2010

switch, default and break in C#

When you "switch" from C++ to C# and want to use "switch" statement, do not forget on of the major differences between switch in C++ and switch in C#:

Unlike the C++ switch statement, C# does not support an explicit fall through from one case label to another. (here)

Even default must have it's own break now - otherwise you'll get a following message from compiler:

Control cannot fall through from one case label ('default:') to another.

So, do not forget break for default

switch(...)
{
case ...:
...
break;
...
default:
...
break; // !!!
}


and enjoy!

Sunday, December 27, 2009

HP ProLiant boot failure

After firmware update on HP ProLiant you may encounter following trouble: the machine failes to boot form HDD or USB stick.
The system check routine displays valid boot sector on HDD, but the boot still fails.

The possible reason: check if your box has an external USB HDD attached. Try to detach the USB cable, restart the machine - and enjoy!

UPD: alternatively
1. Boot the box and enter the boot setup
2. Insert floppy boot option between HDD and USB (you shouldn't have any floppy drives, but the boot option is still here)
3. Reboot the box

Saturday, December 05, 2009

Windows Live Writer @Win7

This entry was written with Windows Live Writer @ Windows 7.

I like it!

Wednesday, December 02, 2009

While using "Result to Text" the output is trimmed to 256 chars

The output of query results in SQL Management Studio (Microsoft SQL Server 2005, 2008) is redirected default to Grid(s).

Optionally you may want to redirect them to text (for example, to re-use output as composed statements etc.). You will be wondered, why the same results are displayed complete while "Results To Grid" set and trimmed to 256 chars once you switch to "Results To Text".

The reason is the default setting in Query Options:



Adjust the setting "Maximum number of characters displayed in each column" and enjoy!

Thursday, October 29, 2009

eTrust Realtime Monitor does not start on Windows Server 2003

Once you installed eTrust Agent on Windows Server 2003 be careful in session management.

Following scenarion takes place:
1. Administrator starts first terminal session to the box and sees the eTrust Realtime Monitor started normally.
2. Administrator disconnects (no logout!) the session.
3. Administrator starts another TS or performs logon on the console: Realtime Monitor doesn't start.

While eTrust runs in background and still protects the machine, there's no notification icon in systray neither possibility to start the updates manually, to open eTrust console etc.

Solution: logout all the connected sessions and restart eTrust Realtime Monitor manually ß it worked for me.

Enjoy!

Monday, October 26, 2009

Two of most popular problems with handmade XML

Sooner or later everybody tries to master his/her own XML files using notepad. And sooner or later one gets troubles with it:

1. XmlSerializer reports on Deserialize():

"http://abcde.efg/blabla" was not expected here

Assure the case in the path - xmlns attribute value is case sensitive: http://abcde.efg is not the same as http://Abcde.efg

2. Trying to open a "handmade" XML file in Internet Explorer

Invalid character in content. Error on processing the resource file:///filename

Most popular cause: create XML with notepad and save a ANSI. Once there's a special character in the content (like german Umlaute or french accents) - you'll be notified with the error message above.

The cure: open the file and save as UTF-8.
Check also MS KB

Enjoy!

Friday, October 16, 2009

Generation of designer file failed: The method or operation is not implemented.

Working with AJAX and ReportViewer controls with VS2008 in an Web Application, we've got suddenly a problem: the designer file for a WebForm won't update.
The error in VS error pane sounds:

Generation of designer file failed: The method or operation is not implemented.

After a numerous tries and web searches the workaround is:
1. Delete designer file.
2. Restart VS and reopen the project (important step!).
3. Open a context menu on a victim page (.aspx) and select "Convert to Web Application"

The designer file with correct entries appears immediately.

Enjoy!

Tuesday, October 13, 2009

Timer in managed Windows Service

Writing a managed Windows service be careful trying to implement any timer functionality: Timers from Forms namespace won't work - mostly

Use System.Threading.Timer instead.
A couple things to know:
1. Use the Timer constructor wisely:
public Timer(
TimerCallback callback, // create a private void method with only stateInfo
// argument (the method signature is essential)
Object state, // can be null if you do not plan to use a sync object
int dueTime, // delay before first timer event gets fired
int period // timer event interval - what else
)
2. Use Change method to Stop/Restart the timer:
public bool Change(
int dueTime, // set Timeout.Infinite to stop the timer or smth else to continue
int period // see above
)

3. Do not forget to Dispose() the timer when it is no more required

Enjoy!

Thursday, October 08, 2009

BizTalk 2009 configuration error 0x80070002 deploying Microsoft.BizTalk.GlobalPropertySchemas.dll

Seen this week: installing BizTalk 2009 x64 on two machines farm (one SQL 2008 SP1 and the second BizTalk 2009) - both Windows Server 2008 R2 Enterprise - we encountered permanent error configuring BizTalk group:

[INFO] WMI Deploying 'C:\Program Files (x86)\Microsoft BizTalk Server 2009\Microsoft.BizTalk.GlobalPropertySchemas.dll'
[WARN] AdminLib GetBTSMessage: hrErr=80070002; Msg=File not found

The cause of the error is DTC: you have to configure DTC on BOTH the SQL and BT boxes according the BizTalk installation guide.
What more to check:
- SQL server protocols enabled? (TCP/IP, Named Pipies)
- Firewall rules on BOTH machines should enable SQL connection
- DTC rules must be enabled on BOTH nachines.

Once we checked and implemented the requirements above - the BT group was installed in minutes.

Enjoy!

Thursday, September 24, 2009

Remote Managemet for DLINK DIR-100 problem

If you have an DIR-100, you may encounter a problem with setting remote management.
The manual says: just enable the remote management, select the port and save the settings...

Do not believe! Until you reboot the router, you will unable to contact to your router from internet.

If the DLINK guys read this post: you'd better update the manual and online help of this router.

Once the router rebooted, you can manage it over Web.

Every boot does good!

Enjoy

Add Windows Server 2008 R2 DC to existing Windows Server 2008 domain

Clear situation: you run a domain using Windows Server 2008 (SP1) and going to add an additional DC. But this time you plan to have a DC running Windows Server 2008 R2.
The Microsoft article describes all the preparation steps you need.

But once you start dcpromo on the new DC, you fail with an error message saying you have to run adprep /forestprep prior to add the new box as DC to the domain.

The adprep utility is resided under \support\adprep on the setup disk of Windows Server.

The clue is:
1. Copy adprep folder from setup disk of Windows Server 2008 R2 to the current DC running Windows Server 2008 (previous version).
2. Start it from there, watch for errors and expect successful finish.
3. Re-run dcpromo on the Windows Server 2008 R2 box.

Attention! Do not use adprep from Windows Server 2008 (the version of OS running on the existing DC), take the newest one (from Windows Server 2008 R2).

Enjoy.

Update: here the schedule worked for me

1. Starting with domain running W2K8 you are going to replace the DC with W2K8 R2
2. You setup a W2K8 R2 machine and make it domain member
3. You add the AD services role to the this new machine
4. You look for setup media with W2K8R2 bits and copy the \support\adprep folder to the W2K8 OLD DC!!!
5. You open an TS to the W2K8 OLD DC and start “adprep /forestprep” – watch for messages, must finish successfully!
6. You switch to the new W2K8R2 machine and launch dcpromo promoting the new W2K8R2 box to be an additional DC in the forest.
7. Do not forget to replicate DNS on this step. Mostly the DNS service is not running on this step and will need a time to start and synchronize with the OLD DC!!!
8. After a while start “active directory sites and services”.
9. Expand until you will see the – at least two – leaf nodes: one is your OLD DC and one is the NEW ONE.
10. Create new connections for replication on the new DC and let it replicate.
a. First you may receive an error with RPC server not available
b. Wait a couple of minutes until DNS synchronizes
11. After a while comes the message about succeeded synchronization.
12. You are done, lucky you! Now the old box can be powered down…