Wednesday, September 29, 2010

Enable IIS7 website for https protocol using SSLDiag 1.1

One of requirements in the current II7 Web Application project was parallel web access to the application using both http and https protocols (LAN users use http, WAN user use https).
IIS does support both protocols (bindings) web site (look into IIS manager):
image
The bindings list informs about all the configured bindings for the website:
image
If you have a SSL certificate installed, you can create the https binding for the site directly: press “Add…” and set the parameters, finally select the certificate.
image
In most cases you do not have any SSL certificates for your development or test/staging environment and are looking for an easy alternative. Or you are going to create a https bindings for the local IIS7 website to be develop/test/debug your Web Application using Visual Studio – the URL used this way starts usually with http://localhost and conflicts with installed SSL certificate if any (the error message says, the certificate was issued for <machine name>, but URL uses localhost as machine name – certificate’s CN mismatch).
SSLDiag is you friend here
image
This free-of-charge IIS tool can be found on Microsoft downloads Website. It creates SSL certificate and “signs” the website for https binding.
Before you start, be sure to download the correct version: there are x86, x64 and ia64 versions of SSLDiag. None of them can replace another one – refer to your machine architecture and current OS version running.
Then download and setup the SSLDiag – freely using default settings.
After SSLDiag is installed, launch it as administrator (it is essential! otherwise SSLDiag cannot read the contents of IIS metabase) and inspect currently configured Websites:
image
The IDs in square brackets are IDs of configured Websites: you will need them to point SSLDiag to a Website you plan to instrument with https binding.
Assume, we like to add a https binding to Default Web Site (having mostly ID W2SVC/1)
  1. Open console window as Administrator and navigate to SSLDiag folder (usually %Program Files(x86)%/IIS Resources/SSLDiag):
    image
  2. Launch following command:
    image

    >ssldiag /s:W3SVC/1 /selfssl /n:CN=localhost /v:500

    where
    /s:W3SVC/1 – ID of the Website to get https binding
    /selfssl – the certificate to be created must be self-signed
    /n:CN=localhost – the certificate must be issued for “localhost” machine; it is essential to develop/test/debug local Web Applications with Visual Studio
    /v:500 – the certfiicate must be valid 500 days (or whatever time interval specified here in days)
  3. Start SSLDiag UI and inspect the changes made:
    image
  4. You may get following warning:
  5. #WARNING: SSL port (SecureBindings property) is not set
    In this case got to IIS Manager and set the binding, selecting “localhost” certificate:
    image
    Ensure the selected certificate was issued for desired machine name (localhost) and is valid specified above number of days (press View to inspect certificate):
     image
    After you added https binding to your Website, you will see it in the bindings list:
    image
    …and IIS Manager will offer Browsing over the SSL Port (default 443) additionally to the usual http port 80:
    image
    So you finished: the website can now be accessed using http and https protocols:
    image
    image     
         
    Click on the lock symbol in address line (IE9 and some older versions) - and  you get additional information about used SSL certificate:
    image
    and view certificate details:
    image
    Enjoy!

Update Adobe Reader failed: This installation is forbidden by system policy (Error: 1625)

Adobe Reader Updater may report following error on Windows 7/Windows Server 2008 R2:

x10sctmp

UAC may be reason for that.

  1. Run Adobe Reader as Administrator (use “Run as Administrator” context menu option on the Adobe desktop icon, for example).
  2. Select Help –> Check for Updates
  3. Follow the instructions: the update should succeed now.
  4. Enjoy!

Monday, September 27, 2010

Problems installing SQL 2008 R2 Developer edition on virtual machine

This is a standard way for me: create a VM (Virtual PC, Virtual Server, Windows XP Mode, Hyper-V), attach an ISO file with desired OS, install OS, attach an ISO file with SQL developer edition, install SQL.

Used it for SQL 2000, 2005, 2008 – now started with 2008 R2: downloaded an ISO file from MSDN subscriptions and used it as described above.

First problems came during the setup: suddenly the setup program reported something like that:

“Could not find module to install”

Setup was interrupted, I tried it over and over again – pretty same result. Bad ISO? Downloaded it again – same result. Somehow I succeeded to continue setup SQL server (using Repair, then add new features to existing instance), but then came another error message I cannot get rid of

“Could not find the Database Engine startup handle”

Fully confused, I burned the ISO file to DVD, mounted it to VM and installed SQL 2008 R2 without problems.

Another VM is running in Hyper-V on a server outside of manual accessibility, so I cannot just put a DVD into the DVD drive and do the same. Here helped WinRAR: extracted all the files in a temporary folder on VM (be sure using a short named path – former SQL installations were not tolerant to LFNs/blanks in path name etc.) and started the setup as usual – succeeded!

Summary: the solution is – either try to burn the image to a DVD and use the physical drive or extract the files using WinRAR and start the setup from filesystem.

Just mounting an ISO file as a virtual DVD is not suitable for SQL 2008 R2 developer edition – this is my experience. Since the setup of SQL 2008 R2 is not a-couple-of-minutes-business, this solution may save you a big portion of your time (despite of nerves).

Enjoy!

UPD: Similar problems are described here:

http://www.msbicentral.com/Resources/Articles/tabid/88/articleType/ArticleView/articleId/80/FLASH-SQL-Server-2008-R2-Error-Could-Not-Find-Database-Engine-Startup-Handle.aspx#Comment17

Sunday, September 26, 2010

Cannot edit blog post title, why?

Just published a post here and minutes later detected a typo in the title. But the web frontend does not allow me edit the title: I can mark and delete characters, but no response when I type a new character. Is it a bug or a feature?
If "blogger" technical guys do read this - please put your suggestions in comments below. Thx...

Get rid of “Please wait while the installer finishes determining your disk requirements” message while installing software on a VM (VPC, WIndows XP mode or Hyper-V)

Already prepared hundreds of virtual images for different virtualization environments, installed thousands of software packages – I’ve encountered today a very strange problem. Trying to install SSLDiag on a W2K8 VM, I’ve got a warning dialog and cannot continue:

image

The solution is (at least, it helped me) described here:

http://bloggingabout.net/blogs/harold/archive/2009/01/14/windows-installer-doesn-t-finish-determining-disk-space-requirements.aspx

  1. Copy the MSI package down to a local folder.
  2. Open elevated console (administrator privileges) and navigate to this folder.
  3. Launch following command:
    msiexec /package <Package name> /qr

Enjoy!

Thursday, September 23, 2010

Tracing network traffic of a custom WebService/WCF client running natively on x64 Windows

Assume you have a custom WebService/WCF Client speaking with your or 3rd party service.

image

The client may be a managed or unmanaged code, but runs on x64 natively (not WOW:ed). One day you may need to discover, what data is really sent/received over the wire (for example, to inspect SOAP envelopes).

The constraints are usually, you aren’t permitted to install on the target box (where client is running) any “hard-artillery” tools like Wireshark.

One of possible solutions is to use a free and footprint-less tool of Microsoft - STRACE:
http://www.microsoft.com/downloads/en/details.aspx?familyid=F5EC767F-27F2-4FB3-90A5-4BF0D5F4810A&displaylang=en

Based on “detours” utility and designed for Internet Explorer tracing, the tool is also useful to trace socket activities of nearby any custom Windows application sending/receiving data over the network.

Since 2009 offers the STRACE support also for x64 versions of Windows.

Here is a short manual, what to do if you are going to trace the socket traffic of your custom application running on x64 version of Windows.

1. Install STRACE from the location above. You will get a folder called STRACE with subfolder x64 containing bits required to run on the x64 Windows.

clip_image001

2. Start your custom client and detect process ID of your application (using, for example, Task Manager or Process Explorer)
image

3. Assume, your client application has a process ID 4976. Open Console AS ADMINISTRATOR (it is essential!) and navigate to the STRACE folder. Then issue the following command:

c:\program files (x86)\strace>runelevate x64\injdll /d:x64\strace.dll /p:4976

clip_image001[6]

runelevate – ensures the elevation of user access privileges to administrator level if UAC is active
x64\injdll – injects the strace.dll into the process space of custom application for tracing of the network traffic
/d:x64\strace.dll – points to the suitable version of strace.dll, doing the trace job. It is important to specify the correct library since there’s no way to inject any 32bit library into 64bit process and visa versa.
/p:4976 – specifies the process ID where we are going to inject strace.dll into.

After you launched the command above, the tracing will start as soon as first network communication will be issued by or for the specified process. Same time the STRACE creates a logfile (usually on your desktop), named according following regulations

STRACE_<process name>_PID_<process ID>_<date>_<time>.LOG

This file contains all the socket conversations of your application:

image

To stop the tracing – just close your application. The injection will not be done automatically on application restart.

Enjoy!

Wednesday, September 22, 2010

Remove FILESTREAM support from SQL Server 2008 (also R2) database: Part 2–Visual Studio Database Project

Well, after FILESTREAM support is removed from your database definitions, you will definitely like to update your visual studio database project.

Started as always – compare schema definitions, write updates. But the FILESTREAM sql’s are not removed. Trying to remove it manually (just exclude from project) causes an error, saying <unnamed> has reference to non existing file group FILESTREAM.

Checked all the files in project manually – no references to FILESTREAM at all. Rebuild – same error.

The source of the message is the .dbmdl file still containing references to FILESTREAM. This file is a binary one and cannot be edited.

Workaround:

  1. Close VS if open.
  2. Manually rename the .dbmdl file (for example, in .dbmdl.org – just for rollback if required).
  3. Start VS and open the database project.
  4. Exclude FILESTREAM dependent sql Script under <your project>\Schema Objects\Database Level Objects\Storage\Filegroups.
  5. Exclude FILESTREAM dependent file definition sql script under <your project>\Schema Objects\Database Level Objects\Storage\Files.
  6. Rebuild and redeploy the project – you shouldn’t see any references to FILESTREAM in output window and in the target database as well.

Enjoy!

Tuesday, September 21, 2010

Remove FILESTREAM support from SQL Server 2008 (also R2) database

The FILESTREAM feature came with Microsoft SQL Server 2008 and offers a very promising functionality in processing of large data portions. Unfortunately, this function does not allow usage of database mirroring as a high availability feature of SQL database:

http://technet.microsoft.com/en-us/library/bb895334.aspx#DatabaseMirroring

Sometimes you may be happy with just varbinary column type: but if you plan to configure your database for mirroring you have to remove FILESTREAM support form your database completely.

One possible solution is described here:

http://beyondrelational.com/blogs/jacob/archive/2010/03/11/completely-removing-filestream-features-from-a-sql-server-2008-database.aspx 

Alternatively you may use some easier way with SQL Management Studio:

  1. Start SSMS and navigate to your database.
  2. Select tables using FILESTREAM in column definitions and generate DROP and CREATE scripts for them
    (you may need also to DROP and recreate additional tables bound via foreign keys).
  3. Remove FILESTREAM and FILESTREAM_ON directives in table definitions.
  4. Re-create tables.
  5. Open database properties and remove FILESTREAM file group.

That’s all.

If your database contains data, you may need to export the data (before 2) and re-import them (after 5).

Enjoy!

Saturday, September 18, 2010

Internet Explorer 9 Beta – first impression

Since a couple of days I’m using it – what a change!

I can’t stand to say: I really love this version!

Install it from here:

http://www.microsoft.com/ie9

and enjoy!

image

Friday, September 17, 2010

4Shared Toolbar 5.7.2.2 causes Internet Explorer 9 Beta crash

Just installed IE9 Beta on one of my boxes running Windows Server 2008 R2: previous IE version was 8 – with minimum of add-ons.

The 32Bit version of IE9 Beta crashes immediately – and does it in cycle: one crash dialog window closes - the next one opens immediately. The 64Bit version does work properly, but… the pages using 32Bit extensions (ActiveX etc.) do not work – as by design.

Investigation starts with launch Internet Explorer with alls add-ons disabled:
image

c:>Program Files(x86)\Internet Explorer\iexplore –extoff

Then disable all add-ons (I’ve disabled all but Microsoft extensions) and restart IE. Step by step enable add-ons and restart IE – until it crashes on start.

In my case it was 4Shared.com Toolbar version 5.7.2.2.

image

BTW, there’s a very interesting article from Mark Russinovich, describing high-level investigation of random IE crash using debugging techniques: http://blogs.technet.com/b/markrussinovich/archive/2010/06/01/3335060.aspx

Using custom URL with Microsoft SQL Server Reporting Services

Last week we were faced to following problem: the customer uses SSRS on a server. The SSRS are installed in the server’s root (as by default): http://server.domain.tld/ReportServer. On the same server runs another custom solution under http://server.domain.tld/CustomSolution. The security regulations restrict browsing access to the root folders of the web sites: only URLs starting with http://server.domain.tld/CustomSolution are permitted, all others (also the SSRS URL is blocked from browsing on the workstations). The goal is to let the users load and see the SSRS reports.

The first idea was to configure the default SSRS URLs using SSRS configuration tool or modifying rsreportserver.config manually – as described in http://msdn.microsoft.com/en-us/library/bb677364.aspx. So we tried to configure SSRS to run in http://server.domain.tld/CustomSolution/ReportServer. It didn’t work because there’s a collision between ASP.NET and SSRS http handlers: both are trying to process the request, but ASP.NET by default wins.

Since the URLs with root folder other than CustomSolution are blocked only on the workstations and not on the servers, we decided to implement following solution:

  • add a new aspx WebForm containing just ReportViewer WebControl – ReportViewerPage.aspx;
  • initialize the ReportViewer WebControl with ReportServer URL and Report Path on page load;
  • put this WebForm under the permitted URL (for example, http://server.domain.tld/CustomSolution/Reports/ReportViewerPage.aspx).

…and it works!

Solution steps

  1. Create a WebForm ReportViewerPage.aspx (source below).
    This form contains ReportViewer WebControl, which is initialized in OnLoad() method. The two request parameters: “report” and “reportServer” are used to initialize the ReportViewer WebControl’s parameters ReportPath and ReportServerUrl respectively.
  2. Put this form under an unblocked path (for example, http://server.domain.tld/CustomSolution/ReportServer/ReportViewerPage.aspx);
  3. Add following line to <httpHanlders> section of your web.config:

    <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    ATTENTION: .NET 4.0/SQL 2008 R2 may have to change Version from 8.0.0.0 to 10.0.0.0 – both in web.config and .aspx file!
  4. Browse the reports using ReportViewerPage.aspx: specify report path and report server URL in the request as follows:

    http://server.domain.tld/CustomSolution/ReportServer/ReportViewerPage.aspx?report=%2fCustomeReports%2fReport1&reportServer=http:%2f%2fserver.domain.tld%2fReportServer

    Be aware to replace all the slashes ‘/’ in the URL with %2f and …enjoy!

image

ReportViewerPage.aspx:

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected override void  OnLoad(EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["report"] != null)
            {
                // set report path
                this.ReportViewer.ServerReport.ReportPath = Request["report"];
            }
            if (Request["reportServer"] != null)
            {
                // set report server URL
                this.ReportViewer.ServerReport.ReportServerUrl = new Uri(Request["reportServer"]);
            }
        }
        base.OnLoad(e);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">’
<head runat="server">
    <title>ReportViewer</title> 
</head>
<body>
<form id="form1" runat="server">
<!--  mb: required for ReportViewer usage -->
<asp:ScriptManager ID="ScriptManager" runat="server">’
</asp:ScriptManager>
<div>
<!-- mb: ReportViewer WebControl itself -->
<rsweb:ReportViewer ID="ReportViewer" runat="server" ProcessingMode="Remote" Width="2200px" Height="1000px">
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>

Thursday, September 16, 2010

Wednesday, September 15, 2010

Invalid object name ‘sys.configurations’ while connecting to SQL Azure database via Microsoft SQL Server Management Studio

Just created a database in SQL Azure using Web UI – and promptly tried to connect using SSMS.

Failure:

image

Message:

Cannot connect to <servername>
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Invalid object name 'sys.configurations'. (Microsoft SQL Server, Error: 208)

The workaround is:

  1. cancel the first connect dialog box showed on start of SSMS
    image
  2. start with empty SSMS UI
    image
  3. Open “New Query…” –> the “Connect to server” dialog appears immediately:
    image
  4. Enter the connection data and press “Connect” – it should work now:
    image
  5. …enjoy!

More about this trick here (thanks to Stan Kitsis).


UPD: SSMS 2008 R2 worked as expected

Setup Development Storage for Windows Azure, DSInit failure

Using freshly installed Windows Azure Tools with VS10 you may encounter following error:

Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance ‘localhost\SQLEXPRESS’ could not be found.   Please configure the SQL Server instance for Development Storage using the ‘DSInit’ utility in the Windows Azure SDK.

That means, the Development Storage wasn’t initiated properly on the box you are using. To init the storage you have to use the DSInit utility from Windows Azure SDK – to find in:

C:\Program Files\Windows Azure SDK\v1.2\bin\devstore

If you have a complete SQL 2008 installation on your computer, you may encounter following error after DSInit starts:

Failed to create database 'DevelopmentStorageDb20090919' : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Unfortunately, DSInit tries to create Development Storage databases in a SQLEXPRESS instance, that is not here. So, your task is to specify the SQL instance to use for Development Storage database creation.

Use DSInit command line switches as follows:
image

c:\Program Files\Windows Azure SDK\v1.2\bin\devstore>dsinit /sqlInstance:. /forceCreate

and enjoy!

More to find here and here.

UPD: using /silent switch in the command line will suppress the progress and confirmation dialog, so you do not have to confirm end of process.

Monday, June 21, 2010

Install Windows XP x86 on DELL Alienware m11x

The challenge was: install Windows XP 32bit on the Alienware m11x notebook, delivered with preinstalled Win7 x64. Do not  ask, why – just accept it :-)

There are some TODOs to get it running properly:

TODO: Copy WinXP setup file to USB Stick, make the stick bootable.

Well, the notebook has no DVD/CD ROM, and I had no external drive, so copied the setup files onto the USB stick.

TODO: Backup existing Win7 installation for fallback purposes, check if the backup can be restored properly.

Backup’ed the existing Win7 installation using built-in Win7 backup to network share.

TODO: Check and adjust the target partition.

Since the note book comes with 3 partitions on the HDD (internal hidden service partition, hidden recovery partition and >400 GB partition for OS and data), you may want to split the work partition to two or more (OS + data, to be able to restore only OS without backup and restore also your data).

Keep in mind to format the partition with NTFS.

TODO: Boot the computer and go to BIOS setup (use F2), change AHCI HDD mode to ATA.

Otherwise, you fail to setup Windows XP: the error “Cannot find temporary files” will be shown.

TODO: Boot from stick you configured above, press F12 on start and select USB drive.

Funny, I tried different sticks: some can boot the notebook using “USB drive” boot option, some only “Removal device” option…

TODO: Start winnt.exe from [USBDRIVELETTER:]\[PATHTO WINDOWSSETUPFILES]\I386 folder.

This must work. Enjoy it!

The only problem I still have: there are really few Windows XP drivers for this notebook available: video, sound, mouse/touchpad, keyboard are running, I’m still missing:

  • WLAN
  • NIC
  • WebCam
  • CardReader
  • 1394

Any ideas?

Sunday, June 13, 2010

ASP.NET error “Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server”

Using SQL based state management for ASP.NET 2.0 aplications you may encounter following error:

6/12/2010 7:58:15 AM Frontend.Web.Main.Global Error Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.
at System.Web.SessionState.SqlSessionStateStore.SqlPartitionInfo.GetServerSupportOptions(SqlConnection sqlConnection)

What to do?

  1. Ensure the ASP.NET state management database is created on the desired database server.
    Keep in mind the command to create such a database:

    aspnet_regsql -S <servername> -E -ssadd -sstype p

    The database should appear in the management studio like:

    image
  2. Ensure the database server and (optionally) the database – if the name differs from the default ASPState – are referenced properly in the web.config in you application:

    <system.web>
    <sessionState mode="SQLServer" sqlConnectionString="Integrated Security=SSPI;data source=<servername>;" timeout="30" cookieless="false">
    </sessionState>

  3. Check the account of the application pool your application is running in:

    image
  4. This account should be granted following permissions in the ASPState database:
    - data read
    - data write
    -execute stored procedures
    image
  5. Usually there’s no dedicated role for stored procedure execution, so create one using “Roles –> Database Roles” editor in management studio:
    - create a role like db_spexecute
    - in “Securables” section add all the dbo. stored procedures related to ASPState managementimage
    - include your application pool account in the newly create role
    image
  6. If you performed all operations correctly, you don’t even need to restart IIS or the WebApp – it just works. Enjoy!

Monday, June 07, 2010

James Utzschneider @ Linux Tag in Berlin

James Utzschneider speaks about MS and OpenSource interoperability @ Linux Tag in Berlin Jun. 10th 2010.

Enjoy also Twitterchannel (in german).

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!