Thursday, September 30, 2010

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.