Monday, February 7, 2011

Wednesday, August 4, 2010

Setting up Service broker after restoring a database.

With a
Service Broker

application, if you have a Test environment where Production backups are restored, it often becomes necessary to reconfigure the service broker after restoration.I first look at the msdb sys.routes table to get the broker_instance.


SELECT name, remote_service_name, broker_instance
FROM msdb.sys.routes

I compare the value of the broker_instance with the service_broker_guid of the DB restored.
SELECT name, database_id, service_broker_guid
FROM sys.databases
WHERE is_broker_enabled = 1

If it does not match, use the ALTER ROUTE command to change the instance value. In case, you rename the older DB, you will end up with two databases having the same broker_instance. In such a case, you can change the GUID associated with the old database

ALTER DATABASE DB_OLD SET NEW_BROKER WITH ROLLBACK IMMEDIATE

and disable the broker for that DB.

Finally, for the restored DB, change the route to point to the appropriate server.
ALTER ROUTE TargetService
WITH
ADDRESS = 'tcp://address:port'

Date of last broker queue activation

The last time service broker queue was activated can be found using the below query.

SELECT q.name, last_activated_time
FROM sys.dm_broker_queue_monitors qm
JOIN sys.service_queues q
ON q.object_id = qm.queue_id

Note that last_activated_time is in UTC format and will need conversion to the appropriate timezone for analysis.

Finding date when message was sent by Service Broker

The sys.conversation_endpoints table has a lifetime column. You can use that to determine the time when a conversation was started as follows.

SELECT DATEADD(SECOND, -2147483647, lifetime) FROM sys.conversation_endpoints e
WHERE e.conversation_id in ('CAAB52B9-C6B3-4DD8-9E1F-7C0CD93D7724', '7AD93224-3700-4054-9BD2-7B52C9430C17')

Friday, December 11, 2009

MS Project TFS binding improves tracking.

Just a few days ago, I setup a binding between TFS work items and MS Project Plan. It required me to use the TFSFieldMapping utility and modify some mappings based on the custom work item definitions we have in TFS. I am now able to better track work items assigned to my team. I would really recommend this for a project using TFS & MPP.

Thursday, July 16, 2009

Excel Type mismatch error when adding Pivot Table.

When creating a pivot table from an Excel ListObject, it is important to use the R1C1 format when passing the range information to Excel's PivotCaches.Add method. Failure to do so will cause the method call to fail with the message "Type Mismatch" when the number of rows exceeds 65,536.

Friday, July 3, 2009

Performance counters to monitor ASP.NET web site performance.

I found it useful to track the following performance counters when monitoring the performance of a web application.

\.NET CLR Interop(WebDev.WebServer)\# of marshalling
\.NET CLR Jit(WebDev.WebServer)\% Time in Jit
\.NET CLR LocksAndThreads(WebDev.WebServer)\Contention Rate / sec
\.NET CLR Memory(WebDev.WebServer)\# Bytes in all Heaps
\.NET CLR Memory(WebDev.WebServer)\Large Object Heap size
\.NET CLR Security(WebDev.WebServer)\% Time in RT checks
\ASP.NET Applications(__Total__)\Requests/Sec
\ASP.NET\Request Execution Time
\ASP.NET\Requests Queued
\Distributed Transaction Coordinator\Transactions/sec
\Memory\Available MBytes
\Memory\Pages/sec
\PhysicalDisk(_Total)\Avg. Disk Queue Length
\Process(sqlservr)\% Processor Time
\Process(WebDev.WebServer)\% Processor Time
\Processor(_Total)\% Processor Time
\SQLServer:Exec Statistics(Average execution time (ms))\DTC calls
\SQLServer:Locks(Database)\Lock Waits/sec
\System\Context Switches/sec
\System\Processor Queue Length
\Web Service(Default Web Site)\Anonymous Users/sec
\Web Service(Default Web Site)\ISAPI Extension Requests/sec

Caching in Outlook

A very informative KB article on Offline Address books in Outlook. Must read for anyone designing offline support in an application.

Outlook.sharing.xml.obi contains RSS subscription names.
extend.dat is an internal cache file used by Outlook to store paths to all DLL files used for Outlook extensions.

Sunday, June 28, 2009

Interesting articles on Green Computing

http://green-broadband.blogspot.com/2007_12_01_archive.html
http://www.environmentalleader.com/2008/05/08/cutting-the-internets-carbon-footprint/
http://technology.newscientist.com/channel/tech/dn13831-delaying-data-could-cut-nets-carbon-footprint.html
http://www.zdnetasia.com/news/business/0,39044229,62042955,00.htm
http://mashable.com/2007/08/14/green-toolbox/
http://www.triplepundit.com/pages/offsetting-your-websites-carbo-003500.php
http://orangecounty.craigslist.org/cps/877592813.html
http://software.intel.com/en-us/articles/creating-energy-efficient-software-part-4
http://www.processor.com/editorial/article.asp?article=articles%2Fp3032%2F23p32%2F23p32.asp
http://www.climatesaverscomputing.org/tools/applications/
http://cultureofchemistry.blogspot.com/2007/05/carbon-footprint-of-that-computer.html
http://www.viapc-1.com/index.php?option=com_content&task=view&id=526
http://blog.tmcnet.com/green-blog/2007/07/the-real-carbon-footprint-of-a-web-page.html
http://www.internetnews.com/reporters_notebook/article.php/3690411

Useful developer links for .NET

1. Customizing the places bar in Visual Studio: Allows you to quickly access frequently used folders.
2. Copy Source as HTML for Visual Studio 2008
3. Smart Client Software Guidance
4. Microsoft Network Monitor
5. Team Foundation Power tools
6. Process Monitor
7. VSTO Power tools

Thursday, June 11, 2009

Relation between Excel Range Locked property and Sheet Protection.

Sheet/Workbook State

Range Locked Property

Result

Protected

True (Default is true)

Range is read-only

Protected

False

Range is editable.

Unprotected

True

Range is editable.

Unprotected

False

Range is editable.

Thursday, May 21, 2009

Listing only directory or file names using the Dir command

The following command can be used from the DOS command prompt to only see the list of filenames/folders in a given directory.

Dir /d /b

Monday, May 4, 2009

Skipping strong name signature verification

I built a VSTO project on my dev box and received the following error when Excel opened up.

Customization could not be loaded because the application domain could not be created.

************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.IO.FileLoadException: Could not load file or assembly or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key

One way to get around this exception is to use the sn.exe utility with the 'Vr' flag.

sn –Vr <assembly>

You can use the Vl flag to see the list of assemblies registered for strong name verification.

Monday, October 6, 2008

InfoCard download issue & response caching.

I have been studying the Zermatt code samples over the weekend in order to see how I can issue a managed card to an authenticated user of my web application that uses Windows Live Id authentication service. So after a user is authenticated, there is a button to be clicked to download the infocard. When I tested this on Firefox 3.0, the download worked fine. But on IE 7, I got an error message.

---------------------------
Windows Internet Explorer
---------------------------
Internet Explorer cannot download signin.aspx from localhost. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
---------------------------
OK
---------------------------

This was happening because of the following statement in Page Load event
Response.Cache.SetCacheability(HttpCacheability.NoCache);
was causing the download of the infocard to fail.

What does this statement do?
With this statement in the code, the response sent back to the client has "Cache-Control: no-cache" in the header.

Why should this error occur on IE, but not firefox?
IE, probably, handles "no-cache" setting without errors when the response is "text/html" encoded. In my case, I was returning a "application/x-informationcardfile" in the response and I guess IE threw up the error message since it could not find how not to cache this response.
Firefox 3.0 just ignores the cache-control HTTP header.

I replaced the offending statement with
Response.Cache.SetNoStore();
and the file download works fine on both IE & Firefox.

References:
1. File download problem with Response.Cache.SetCacheability
2. Cache directives ignored by Firefox in ASP.NET caching.

CardSpace STS error: Certificate used has a trust chain that cannot be verified

When trying to run the Simple STS sample application, I came across this message.

The certificate used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. The revocation function was unable to check revocation because the revocation server was offline.


On further investigation, I realized that the revocation server was set to http://www.adatum.com in the sample certificate. I had an entry for http://www.adatum.com in the Hosts file on my dev box. But it was not configured under IE Options > Connections > LAN Settings > Advanced > Proxy Settings > Exceptions. On adding the missing entry in the Exceptions text box, the error was fixed! Here is a list of commor errors when running cardspace samples.

Friday, October 3, 2008

SSL setup issue in Zermatt Beta.

I downloaded Microsoft Zermatt Beta and was enthusiastically working to get the samples setup. When running the script SamplesPreReqSetup.bat, I got the following error in the SSL setup step.

C:\Program Files\Microsoft Code Name Zermatt\Samples\Utilities\Scripts\SetSSLCertificate.js(32, 1) (null): The system cannot find the path specified.

On having a look at the script, I found that the code was not able to find the path "/W3SVC/1" in the metabase.xml. The setup script assumes that the default web site is available at the path /W3SVC/1. On opening up metabase.xml, I found that the Default Web Site on my server was set to "/LM/W3SVC/998577302". I guess that the Default Web Site was probably deleted and reconfigured on this box. Hence, it had a different value for the Location attribute. :). As a fix for this, I have replaced the following line in SamplesPreReqCleanup.bat
cscript //nologo "%~dp0Scripts\SetSSLCertificate.js" /W3SVC/1 %localhostCERTHASH%

with the one below.
cscript //nologo "%~dp0Scripts\SetSSLCertificate.js" /W3SVC/998577302 %localhostCERTHASH%

How to fix "Theme cannot be found errors"

Wiith the following Website structure.
- Default Web Site
  - vdir1
    - App_Code
  - App_Code
  - App_Themes
    - GlobalTheme

when I queried for a page http://localhost/vdir1/Test.aspx, I got the following error message "ConfigurationErrorsException: Theme 'GlobalTheme' cannot be found in the application or global theme directories". The fix for this was simple. I had to create a sub-folder named App_Themes under vdir1 as shown below.

- Default Web Site
  - vdir1
    - App_Code
    - App_Themes
      - GlobalTheme
  - App_Code
  - App_Themes
    - GlobalTheme

Where is HttpCfg?

I downloaded a few samples for trying out Windows CardSpace. One of the setup scripts used HttpCfg to configure SSL and it failed to execute since it could not find HttpCfg. This file, if not on your system, can be installed from [Windows 2003 Setup location]\Support\Tools\SUPTOOLS.MSI. For a complete list of support tools click here.

Windows XP users can download the support tools from here
Windows 2003 users can download support tools from here

What is success?

The journey of life takes us through varied experiences like landing an admission at a prestigious college, earning a degree, getting hired,...