Monday, August 27, 2012

Install and configure TFS 2012 Express on a standalone server

 

Prerequisites

Use Windows Server 2008 R2 Standard SP1 computer (a virtual machine as well) with most recent required updates.

Install application server role (full IIS support recommended).

Create two OS accounts for TFS services (recommended): TFS service itself and TFS build service.

clip_image001

clip_image002

Download TFS Express ISO image (<450MB)

http://www.microsoft.com/visualstudio/11/en-us/downloads#tfs-express

and attach it to TFS server (as Image or as burned CD).

Setup

Start tfsexpress if not launched automatically.

clip_image003

clip_image004

Accept the license and install.

clip_image005

clip_image006

Setup starts.

clip_image007

Confirm automatic restart of the server if required.

After server restarts, the setup continues.

clip_image008

Setup will try to download latest updates after succeeded finish (will fail if there’s no internet connection available).

clip_image009

TFS service configuration

After setup wizard closes, the next wizard starts automatically – the configuration wizard.

clip_image011

Confirm wizard start.

clip_image013

Change TFS Service account context (recommended) using TFS Service account created above – click “Change”.

clip_image014

Enter account name and password, check entered data clicking “Test”.

Change default port number (8080) if required.

clip_image016

Verify changes made or continue directly.

clip_image018

Pre-configuration starts.

clip_image020

Start final configuration with “Configure”.

clip_image022

Configuration finalizing starts.

clip_image024

After configuration finishes continue with “Next”.

clip_image026

The final screen displays the URL to access TFS service (here http://tfsexpress:8080/tfs).

Click on the URL brings opens internet browser (here Internet Explorer, confirmation to unblock web address may appear).

clip_image027

Click “Add” to include the TFS service URL in the list of trusted URLs.

The Web frontend of TFS Service opens.

clip_image029

The wizard can be closed. Alternatively TFS build service may be configured from now.

clip_image031

TFS build service configuration

clip_image033

Continue the wizard with “Next”.

clip_image035

Change the project collection if not the default collection is to be used.

clip_image037

Configure number of build agents.

clip_image039

Change TFS build service account context (recommended) using TFS build service account created above, click “Test” to verify entered data.

clip_image041

Ensure test of entered account data succeeded, continue wizard.

clip_image043

Confirm the configuration settings or verify if required.

clip_image045

After validation of the settings start configuration with “Configure”.

clip_image047

Configuration starts.

clip_image049

After configuration finishes finish the setup with “Next”.

clip_image051

Review setup summary on the final screen.

Finalization

clip_image053

After TFS build service configuration finishes check the summary on the final wizard screen and close the wizard.

clip_image055

TFS express administration console open immediately.

From now you can start to use your fresh TFS express instance and enjoy it!

Friday, August 10, 2012

Check and download Windows updates online for domain member computers

Most administrators configure group policy to use a domain internal Windows Update Server (WSUS), so if you take your domain member computer off the domain network (assume notebook or virtual machine image), the system won’t be updated reporting error: cannot check for updates or cannot download updates.

Windows Update control panel displays following information:
image

“You receive updates:” is configured as “Managed by your system administrator” and “Check online for updates from Microsoft Update” is disabled/grayed out.

The reason is mostly configured group policy, pointing to use a domain update server (WSUS server) as update source.

You can revert your box to get updates online instead of looking for (temporarily?) unavailable update server.

Open regedit on the box and change following registry value

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\UseWUServer

to 0

image 

and retry check for updates:

image

Refer also Microsoft KB http://support.microsoft.com/kb/328010 and enjoy!

Thursday, August 09, 2012

“Go online” problem with Windows Live Mail and MESH (Windows Live Essentials) on Windows 8

 

After enabling Hyper-V feature and configuring Virtual Switch on Windows 8 box we encountered very strange problem: after click on “Work offline” in Windows Live Mail window - globe button clip_image001– the program won’t go back online. Each click on clip_image001[4] “Go online” is followed by

clip_image001[6]

MESH also declines to start saying “There’s no internet connection” or similar.

Workaround:

  1. Close and exit Windows Live Mail and Mesh if running.
  2. Start Internet Explorer.
  3. Ensure “go online” notification on the bottom of internet explorer and DO NOT CLICK “Go back offline” – simply close it.
    clip_image001[8]
  4. Restart Windows Live Mail – you will see, Windows Live Mail went automatically online.
  5. Restart Mesh
  6. Enjoy!

Wednesday, August 08, 2012

Protect ASP.NET application against No-Redir browser hacks

 

Page redirection is a very popular approach on Web applications behavior, for example: count login errors and redirect user to an error page if login error count exceeds max allowed value – to prevent login hack attack.

The simplest way to do it in a ASP.NET application:

// Get URL of the error page to be redirected to
string urlErrorPage = getUrlErrorPage(…);

// Use Response.Redirect to redirect user to the error page
Response.Redirect(urlErrorPage, true);
The problem is, there are numerous add-ons for internet browsers to prevent redirection: like this, this and this.
One possibility to redirect mandatory is to write the content of target page in Response directly (the target page assumed to be plain HTML page):
// Use Response.Write to write error page content
string errorContent = "<html><head></head><body>error</body></html>";
string sFile = null;
try
{
sFile = Server.MapPath(urlErrorPage);
using (StreamReader sr = new StreamReader(sFile))
{
errorContent = sr.ReadToEnd();
}
}
catch (Exception ex)
{
// Handle exception
}
finally
{
Response.Write(errorContent);
Response.End();
}

Once again: the target error page assumed to be (D)HTML page.


Enjoy!

Monday, August 06, 2012

Windows Server 2012 is RTM now

 

For anyone, who doesn’t follow MSDN news: WS2012 is RTM.

Stay online with TechNet evaluation center and enjoy!

UPD: do not miss 4th September – Windows Server 2012 availability start

UPD: do not miss Windows Server 2012 Essentials (currently beta)

Saturday, August 04, 2012

GhostScript error using FreePDF with network share

Some workstations in a Windows Domain (checked with SBS 2003 latest SP and Windows Server 2008 R2 latest SP) have problem saving PDF documents from FreePDF printer.

One of the reason: network share as destination folder – the document is created but copy to the target folder fails generating GhostScript error message.

Workaround: save result PDF document to a local folder and the copy to network share destination.

Enjoy!

UPD: same behavior was seen using CutePDF or Bullzip PDF

Wednesday, August 01, 2012

Problem: "The user name or password is incorrect" if you try to connect to SBS 2003 based network share or Exchange via Outlook

 

Situation: there is a number of client computers in a local SBS 2003 based domain. Every computer but one is domain member and runs Windows XP SP3. All users have access to network share (via explorer) and mailboxes (via Outlook 2003/2010) on the SBS 2003 SP2 server in the domain.

Suddenly the only non-domain computers – a workgroup computer – gets no access to network share and to Exchange mailbox. The user gets repeating error message

"The user name or password is incorrect"

The same username/password pair succeeds on every other computer in the LAN.

The most popular problem is: the clock on the client computer and on the serve are not synchronized. In our case: somebody misconfigured client’s date/time setting the next month as current, so the date/time difference between client and server was 1 month.

After setting client’s date/time same as on the server the access to network shares and Exchange account via Outlook was restored immediately.

So, in case of same or similar error message

  • check the date/time settings on the server
  • check the date/time settings on the client computer
  • compare and synchronize them if required

Enjoy!

Monday, July 30, 2012

Writing this post from Windows 8 To Go

Amazing! I enjoy my Windows 8 To Go on single USB stick.

image

First impressions: Windows 8 Enterprise

image

on a 16 GB RAM box uses 23 GB of 32 GB USB Disk

image

with following software/features installed on Win8:

  • Hyper-V Management Tools (to control my GUI-less Windows Hyper-V Server)
  • MS System Center 2012 Endpoint Protection
  • MS Office 2010 Professional Plus 2010
  • Skype
  • Windows Live Essentials

Friday, July 27, 2012

Cannot access file share on Windows Server 2008 R2 “This server's clock is not synchronized with the primary domain controller's clock”

 

While trying to access a file share on Windows Server 2008 R2, which was accessible just yesterday, you may receive following error message:


\\[Servername] is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

This server's clock is not synchronized with the primary domain controller's clock.

image

The problem is: the server’s clock isn’t synchronized with domain controller’s clock.

  1. Log on to console of the server with share.
  2. Start console with ELEVATED administrator privileges.
  3. Launch following command
    w32tm /resync
    image
  4. In couple of minutes the share is accessible again

Enjoy!

Friday, June 22, 2012

ASP.NET: DropDownList throws an exception “[ctlName] has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value”

 

Yes, you may monitor this exception if your DropDownList WebControl is initialized programmatically, like

ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is exception thrown

If the data source doesn’t include an element with empty string as value, the above mentioned exception is thrown.

The problem is solved with setting SelectedValue of the DropDownList to null:

ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.SelectedValue = null; // <- added to solve
 

                                       // the problem
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is no more exception

Enjoy!

Thursday, June 07, 2012

Windows Server 2012 for download

Yes, the WS12 is here: http://technet.microsoft.com/en-us/evalcenter/hh670538.aspx

Registration required. You can download the .ISO (localized in many languages) or .VHD to bind under Hyper-V

image

The VHD is an exe-archive (~3GB to download), ~8GB extracted.

The administration password will be set on the first start.

I’ve got it running having 3GB RAM.

Download and enjoy!

Monday, May 21, 2012

WinXP: Cannot browse LAN resources (share/printer) or Workstation service won’t start

 

Imagine: you still have an old box running Windows XP bound to your local network. One day you start the box and see the surprise: you can surf in internet, send and receive mails, chat and skype – but you have no access to the local network resources (like server shares or network printers).

Double click on the icon Network –> Microsoft Windows Network opens an error message “The network is not present or not started.”.

You may try the fix from MS knowledge base - http://support.microsoft.com/kb/170336/en-us

If it won’t help: go to services control panel applet and check if the workstation service is started. Probably not. This is the reason.

Try to start it: if the service won’t start – look at the error message. You may receive following error message:

Error 126: The specified module could not be found when starting a service

The possible reason is described here: http://support.microsoft.com/kb/959077.

´The registry on your machine is damaged by a virus and contains unsuitable entry in the key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ lanmanworkstation\parameters\ServiceDll

pointing to a Trojan library module (in our case – aptwanxok.dll). The enemy library may be already removed from your machine, but the registry key is still pointing to it and requires to load blocking start of the service due to missing module.

Replace the entry with

%SystemRoot%\System32\wkssvc.dll

image

restart the computer and enjoy!

Thursday, April 19, 2012

Problem: cannot paste Excel table into Outlook Mail message or Winword document

 

One day you get sudden trouble: the copied Excel table or table portion cannot be pasted into Outlook mail message or Winword document. Only plain text contents appear instead.

Do not search for “hidden” Excel or Office settings. The reason is surprising Skype Click to Tel Add-On

clip_image001

Go to Program and Features (aka Add/Remove Software) and remove the AddOn – the easiest way to get rid of this effect and enjoy!

UPD: see also http://smoothspan.wordpress.com/2012/03/24/omg-skype-click-to-call-breaks-excel-so-it-can-only-paste-text/

Monday, March 19, 2012

Failed file operations with WebDAV using customer error pages on 404 (Not Found)

 

If you configure custom error pages for 404 (Not Found) as redirect to an URL inside the Website may cause problems with file operations via WebDAV.

This setting may be configured using IIS Manager:

image

or with directly editing the Web.config:

<httpErrors>
        <remove
               statusCode="404"
               subStatusCode="-1"/>
        <error 
               statusCode="404"
               prefixLanguageFilePath=""
               path="/index.html" 
              
responseMode="ExecuteURL"/>
  </httpErrors>

When the default 404 handling error pages are configured as above you may encounter problems using WebDAV file operations:

image

image

“File too large”

image

“The parameter is incorrect”

The solution is: each before starting a WebDAV file operation toggle the redirection setting at least fir “Not found” (404) off, perform required file operation and revert the redirection configuration.

Enjoy!

Saturday, March 17, 2012

Howto: configure WebDAV on Windows Azure WebRole instance automatically in deployment package

Last blog entry we configured WebDAV on a WebRole manually. Unfortunately the settings are gone once the WebRole is migrated, re-deployed etc. All the settings must be prepared again.

To avoid this we created a startup task performing all the configuration steps and built it in the deployment.

The steps:

Create a StartupWebDAV.cmd script with following content:

rem configure WebDAV

rem activate WebDAV feature
CMD /C START /w PKGMGR.EXE /l:log.etw /iu:IIS-WebDAV

rem enable WebDAV on the default website
%windir%\system32\inetsrv\AppCmd set config /section:system.webServer/webdav/authoring /enabled:true /commit:apphost

rem set SSL for WebDAV
%windir%\system32\inetsrv\AppCmd set config /section:system.webServer/webdav/authoring /requireSsl:false /commit:apphost

rem set WebDAV authorization rule
rem here: read/write/source for user webdavAdministrator on any path

%windir%\system32\inetsrv\AppCmd set config /section:system.webServer/webdav/authoringRules /+[users='webdavAdministrator',path='*',access='Read,Write,Source'] /commit:apphost

rem enable Windows Authentication
%windir%\system32\inetsrv\Appcmd set config /section:windowsAuthentication /enabled:true

Note following aspects:

  • activation of WebDAV feature logs the events in log.etw file
  • the appcmd set config does not specify Website – the default and only Website assumed; if you have many Websites and want to specify a dedicated one, you need to extend the commands with Website specification – refer to appcmd manual
  • the user name in the sample – webdavAdministrator – must be replaced by real name(s), the user(s) must exist as OS user(s)

Bind the script as startup task in .csdef (service definition) file:

    <Startup>
<
Task commandLine="StartupWebDAV.cmd" executionContext="elevated" taskType="simple" />
</
Startup>


Build, package, deploy, enjoy…

Friday, March 16, 2012

Howto: configure WebDAV on Windows Azure WebRole instance

 

One day you may decide to configure WebDAV on your Windows Azure WebRole instance: for example, to perform file uploads without Azure deployments. BTW, be aware: all uploaded to WebRole instance files which do not exist in the deployment package are irreversible gone when the instance is migrated to another Azure host node or restarted.

But while the instance is running you may use the files uploaded via WebDAV.

Why we use WebDAV on Azure? Well, there was a business process to upload the Web content files to the former hosting platform prior to Windows Azure. The deployment chain includes a WebDAV upload and the tools are configured. Additionally,the uploaded files can be used immediately.With an usual Azure deployment package there is an instance outage for approximately 10-15 minutes. We need to update the files multiple times a day and use WebDAV to provide quick access to updated content files. Once uploaded via WebDAV the files can be accessed immediately. Additionally we update these files to deployment package and deploy then this package overnight while the outage of instance is not so critical.

Here are steps to activate and configure WebDAV on Windows Azure WebRole.

Configure Windows Server 2008 R2 as instance OS

First, be sure you use Windows Server 2008 R2 as instance OS. Windows Server 2008 has no WebDAV setup package out-of-box and requires download and setup of WebDAV modules. Windows Server 2008 R2 has WebDAV setup as feature package and requires only activation and configuration.

To ensure and configure right version of OS launch Windows Azure management portal and open popup menu on the selected deployment:

image

In popup menu select “Configure OS”:

image

You may see Windows Server 2008 SP2 as current OS version:

image

Select “Windows Server 2008 R2” and confirm with “OK”:

image

The system needs some time to be reconfigured:
image

All instances will be updated:

image

After all the instances are reconfigured you may use RDP to open terminal session to each instance to ensure configured OS version. The manual for RDP configuration on Azure is here: http://msdn.microsoft.com/en-us/library/windowsazure/gg443832.aspx

You will need RDP to each instance for WebDAV configuration. Use “Connect” button in management portal:

image

You should see the server configuration window with the current OS version information:

image

Alternatively you can start “winver”:
image

…and see the OS version:
image

Activate WebDAV

WebDAV is a feature of IIS and can be activated via Server Manager:

image

Select “WebDAV” in Role Services:

image

Confirm installation:

image

The installation process begins:

image

Configure WebDAV

Configure WebDAV for Website using IIS Manager:

image

Select “WebDAV Authorization rules” in IIS features of the Website:image

Enable WebDAV for the Website:

image

Once WebDAV is enabled, the option to disable WebDAV appears:

image

Add authorization rule to provide access to the file system, select content type, user(s) and permissions:

image

Review configured rules:

image

Do not forget to enable Windows Authentication on Website – otherwise the WebDAV users cannot login. Use “Authentication” IIS feature of the  Website:

image

Enabled Windows Authentication looks like:

image

Complete!

Access WebRole instance using WebDAV

From now you can access file system on WebRole instance using WebDAV. On the client open Windows Explorer:

image

Select “Map network drive”:

image

Select “Connect to a Web site…”:

image

Add network location:

image

Specify URL to the WebRole where WebDAV is enabled and configured:

image

Enter user login and password when prompted (use credentials you configured in WebDAV authorization rules):

image

Windows Explorer opens the location you configured:

image

You can use ordinary file system functions to upload to or download from WebRole instance.

Enjoy!

Tuesday, March 06, 2012

WMI error: Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa

 

We used WMI from ASP.NET code to get CPU(s) ID for the current host. It worked a while, but suddenly stopped – with message:

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 800703fa

Reload user profile for AppPool identity – as described here – didn’t help.

Once downloaded and run WMIDiag the system came back to running state.

Friday, February 24, 2012

Another way to check database version before automatic deployment

With VS2008 (GDR) / 2010 / 2011 you may use automatic deploy scripts built with VS and based on vsdbcmd.

If you track the database version inside of your database (for example, in a separate table), you may need to check the current database version before incremental update – in some cases you may support the update only for dedicated versions and above and not for older versions.

You can force deployment break in the pre-deployment script after check for database version – if the database version is not supported for update:

--- get database version from current database

select @CurrentVersion =[PARAM_VALUE] from [MySystemParameters]
   where
   [PARAM_NAME] = 'DBVERSION'

--- check the version and break the deployment if the version is not supported

--- the sample is simplified: in real life you will check major version, minor version, build number etc.

if not ( @CurrentVersion >= @MinSupportedVersion)
   begin
      raiserror ('Current database verison is not supported and cannot be updated',18,0)
      set noexec on
   end

When you start the script on the target box, the deployment break looks like following:

x10sctmp

Enjoy!

Thursday, January 26, 2012

Problem with DATEV on changing computer name

Very simply: NEVER CHANGE THE MACHINE NAME once you installed DATEV.

You can join and leave domains and workgroups, but cannot change the machine name.

Once you’ve changed the machine name, you aren’t able to view old bookings and to enter new.

The only way is to revert machine to former name. Enjoy!

Friday, January 06, 2012

XMLWriter ignores XMLWriterSettings: generated XML is “UTF-16” instead of “UTF-8”

Once you need to generate a XML document in your ASP.NET application (for example, to offer it for download), you will sooner or later decide to use the XMLWriter class of .NET Fx.
So you’ll write a piece of code like: 
  
string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
     StringBuilder sb = new StringBuilder();
     XmlWriter xmlWriter = XmlWriter.Create(sb);
     xmlDocument.Save(xmlWriter);
     xmlWriter.Close();
     string strContent = sb.ToString();
     Response.ContentType = "text/xml";
     Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
     Response.AppendHeader("Content-Length", strContent.Length.ToString());
     Response.Write(strContent);
And you’ll be definitely surprised seeing the output XML declaration with encoding “UTF-16”.

Well, extending the code snippet with explicit XMLWriterSettings, you’ll land on:

string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
     StringBuilder sb = new StringBuilder();
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Encoding = Encoding.UTF8;
     XmlWriter xmlWriter = XmlWriter.Create(sb, settings);
     xmlDocument.Save(xmlWriter);
     xmlWriter.Close();
     string strContent = sb.ToString();
     Response.ContentType = "text/xml";
     Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
     Response.AppendHeader("Content-Length", strContent.Length.ToString());
     Response.Write(strContent);
And you’ll be still surprised seeing the output XML declaration unchanged with encoding “UTF-16”.

The reason is, the settings of XMLWriter target (in this sample – StringBuilder) override the XMLWriterSettings parameters already in XMLWriter constructor.

The way out is, use an alternate target for XMLWriter, supporting the encoding you need. For example:

string fileName = buildDownloadFilename();
XDocument xmlDocument = generateXML();
if (xmlDocument != null)
   {
    XmlWriterSettings settings = new XmlWriterSettings();
    settings.Encoding = Encoding.UTF8;
    MemoryStream ms = new MemoryStream();
    XmlWriter xmlWriter = XmlWriter.Create(ms, settings);
    xmlDocument.Save(xmlWriter);
    xmlWriter.Close();
    string strContent = Encoding.UTF8.GetString(ms.GetBuffer());
    Response.ContentType = "text/xml";
    Response.AppendHeader("content-disposition", String.Format("attachment;filename={0}", fileName));
    Response.AppendHeader("Content-Length", strContent.Length.ToString());
    Response.Write(strContent);
Also check the solution here: http://blogs.msdn.com/b/kaevans/archive/2008/08/11/xmlwritersettings-encoding-being-ignored.aspx

Enjoy!