Posts Tagged ‘Zeeshan Shah’

I believe Visual Studio 2010 was the latest and greatest (compared to VS2008 and prior). Well, after a clean installation of VS2010, as I tried to launch the program I received the following error  (on a dialog box)


SetSite failed for package [Microsoft.Practices.RecipeFramework and a dialog box Object reference not set to an instance of an object

The above doesn’t explain much !. I tried running Visual Studio from a command prompt using the log switch
devenv.exe /log
This logged the activity trace of launching Visual Studio under …\AppData\Roaming\Microsoft\VisualStudio\10.0\ActivityLog.xml

On reading the error log, I noticed the following two lines:

SetSite failed for package [Visual Studio Component Model Host Package]
SetSite failed for package [Microsoft.VisualStudio.Labs.SolutionNavigatorPackage,


… and this time something in the event viewer:

Faulting application name: devenv.exe, version: 10.0.30319.1, time stamp: 0x4ba1fab3
Faulting module name: ntdll.dll, version: 6.1.7601.17725, time stamp: 0x4ec49b60
Exception code: 0xc0000374
Fault offset: 0x000c380b
Faulting process id: 0x11f8
Faulting application start time: 0x01cd60b0bd3f8235
Faulting application path: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 1576fd49-cca4-11e1-8bd9-001cc48a5099


This happens because of Visual Studio is trying to load extensions that do no exist on the machine !.  To resolve this, navigate  following registry key, and make sure all directory locations exist under the given paths:

Navigate to:


And directory paths exist on your machine. Screen shot as follows:

A far better resolution could have been out-of-the-box in VS 2010 (dev.exe). Just disable the extension if path does not exist (thanks MS!)

Read Full Post »

Found the following error to be quite a simple fix. Posting incase, someone is looking for a solution.

Error: Communication with MessageBox  BizTalkMsgBoxDb on SQL Instance XYZ/Instance01 has been re-established


Most likely you’d be running BizTalk 2009 (as I found out to be!). Installing the following hot-fix would resolve it:

KB Article Number(s): 980560
Link: http://support.microsoft.com/kb/980560

Happy fixing…

Read Full Post »

In this post, I’ll describe about creating a new message from the existing content.

The following lines calls the method

//Queue to hold disassembled messages
Queue<IBaseMessage>() sendQueue = new Queue<IBaseMessage>();
XDocument xDoc = XDocument.Parse(MessageHelper.GetStringFromMessage(message));

// namespaceURI:string -  Get Namespace
// root:XElement - Root node
AddOutgoingMessage(xDoc.ToString(), pContext, namespaceURI, root.Name.LocalName);

Here is the magic method

private void AddOutgoingMessage(String messageString,IPipelineContext pipelineContext,  string namespaceURI, string rootElement)
IBaseMessage outMsg;
//create outgoing message
outMsg = pipelineContext.GetMessageFactory().CreateMessage();
outMsg.AddPart("Body", pipelineContext.GetMessageFactory().CreateMessagePart(), true);
outMsg.Context.Promote(BtsProperties.MessageType.Name, BtsProperties.MessageType.Namespace, namespaceURI + "#" + rootElement.Replace("ns0:", ""));
     byte[] bufferOoutgoingMessage = System.Text.ASCIIEncoding.ASCII.GetBytes(messageString);
outMsg.BodyPart.Data = new MemoryStream(bufferOoutgoingMessage);
  catch (Exception ex)
    throw new ApplicationException("Error in queueing outgoing messages: " + ex.Message);

Happy coding 🙂

Read Full Post »

Having a small issue with a stored proc executing a “Delete FROM tablename” statement against a (temp) table containing a huge number of rows. In this instance a “truncate table tablename” would have suited better.

From the MSDN documentation
Compared to the DELETE statement, TRUNCATE TABLE has the following advantages:

  • Less transaction log space is used.
    The DELETE statement removes rows one at a time and records an entry
    in the transaction log for each deleted row. TRUNCATE TABLE removes the
    data by deallocating the data pages used to store the table data and
    records only the page deallocations in the transaction log.
  • Fewer locks are typically used.
    When the DELETE statement is executed using a row lock, each row in
    the table is locked for deletion. TRUNCATE TABLE always locks the
    table and page but not each row.
  • Without exception, zero pages are left in the table.
    After a DELETE statement is executed, the table can still contain 
    empty pages.For example, empty pages in a heap cannot be deallocated 
    without at least an exclusive (LCK_M_X) table lock. If the 
    delete operation does not use a table lock, the table (heap) will 
    contain many empty pages. For indexes, the delete operation can leave 
    empty pages behind, although these pages will be deallocated quickly 
    by a background cleanup process.


 Extrapolating on this – if your intention is to simply remove all records from a table, without the need for a rollback – truncate table is significantly more performant.

Happy terminating.. err – truncating 🙂

Read Full Post »

This is one of the most frequent errors you’d see when logging with the Event Log.
Error: Writing to the event log FAILED .. Requested registry access is not allowed. at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)

Most of the time this error goes unnoticed because of the account privileges your application is running under. However, once the environment becomes a bit restrictive – this pops up.






1) Elevate the privileges of your account or impersonate your account to run under a different set of authorization credentials.
==> I’m personally not a big fan of changing account privileges. It should be restricted to its intended “work”. Its more like saying – make me the admin, and I’ll choose whatever I intend to execute 8) !

2) Allow your application to use the event log
This is what is exactly required. The error popped up only because your application is designed to log an event in the event viewer – and asking for permission to write – sounds logical.

To do so, create an event source under the Application event log in Registry Editor. To do this, follow these steps:


1) In your registry, locate the following registry subkey: HKEY_LOCAL_MACHINE à SYSTEM à CurrentControlSet à Services à Eventlog à Application

2) Right-click the Application subkey, point to New, and then click Key
3) Type
<ApplicationName> for the key name.

Replace the
<ApplicationName> with your source.
Reference: http://support.microsoft.com/?id=329291

That’s all folks. Happy logging 🙂

Read Full Post »

It is generally a good practice -during dev work to view the impact that your components could have your application database. Of the many analysis that could be done in this regard ,  one such metrics is the monitoring of locks. SQL provides one such stored proc called the sp_lock. In using this, I have to filter alot “garbage” (things that I would not like to view) just to view my relevant information.

The sp_lock returns this massive list of database ids, resources, etc.  In reality, all I’m intrested in – is to view the process names that create locks on my database. Here is one such handy stored procedure to do just that 🙂 – I’m not claiming that the sp_locks is better or worse than the one below. (fingers crossed).

1) Create the following stored procedure (SQL scipts listed below)

2) Optionally, include it in your master database. This would allow you to run it from any database context and retreive information relative to your database context

EXECUTE sp_ms_marksystemobject 'sp_DatabaseLocks'


3) View your database locks using the command


sp_DatabaseLocks ‘MyCustomDatabase’


SQL Script:

USE [master] 
CREATE PROC [dbo].[sp_DatabaseLocks] @IncomingDatabaseName sysname = NULL,
 @IncomingObjectName sysname = NULL WITH RECOMPILE AS 
DECLARE @sqlCommand varchar(1000) 
DECLARE @DatabaseName sysname 
SELECT    @DatabaseName = Isnull 
 ( @IncomingDatabaseName, Db_Name( ) )

 SELECT    * 
 FROM    master.dbo.sysdatabases 
 WHERE    Name = @DatabaseName 

RAISERROR(15010,1,1,@DatabaseName) WITH SETERROR 
RETURN 15010 
SELECT    @sqlCommand = ' 
SELECT    convert (smallint, req_spid) AS spid,
 rsc_dbid AS dbid,
 rsc_objid AS objid,
 so.Name AS ObjectName,
 rsc_indid AS indid,
 substring (v.name, 1, 4) AS Type,
 substring (rsc_text, 1, 16) AS Resource,
 substring (u.name, 1, 8 ) AS Mode,
 substring (x.name, 1, 5) AS Status 
FROM    master.dbo.syslockinfo sli 
 JOIN master.dbo.spt_values v 
 ON sli.rsc_type = v.number 
 AND v.type = ''LR'' 
 JOIN master.dbo.spt_values x 
 ON sli.req_status = x.number 
 AND x.type = ''LS'' 
 JOIN master.dbo.spt_values u 
 ON sli.req_mode + 1 = u.number 
 AND u.type = ''L'' 
 JOIN master.dbo.sysdatabases sd 
 ON sli.rsc_dbid = sd.dbid 
 JOIN ' + @DatabaseName + '.dbo.sysobjects so 
 ON sli.rsc_objid = so.id 
WHERE    sd.name = ''' + @DatabaseName + '''' 
 @IncomingObjectName IS NULL 
 AND so.Name = ''' + @IncomingObjectName + '''' 
ORDER BY spid' 
IF @IncomingObjectName IS NULL PRINT 'Resource Locks FOR DATABASE ' + @DatabaseName 
PRINT 'Resource Locks FOR DATABASE ' + @DatabaseName + ', Resource ' + @IncomingObjectName 


Happy monitoring 🙂

Read Full Post »

I was working on a prototype around ESB and while designing around the exception management component I thought about posting the “faulty” incoming message to a database. I have had a liking for updategrams recently – simply because they have never let me downJ.


The above scenario sound pretty easy. Get the message, and post it to the database using the updategram in BizTalk – or I thought so!


I started by creating a table with a few columns (with one column specified as an XML data type to store any faulty messages). In my VS IDE, I started building my prototype

à Right click the project to “Add the Generated item” 

à Set up the connection string

à Select the target namespace (Send port)

à Select updategram

à Select table à ERROR







Error: Unable to obtain schema for the query. Check that table does not contain a column of type xml.













1)  Change my table structure to accept a varchar instead!

Changing my DB structure to make BizTalk work! Surely – it doesn’t sound right to me. But IF I did – I know BizTalk would be happy with the updategram data type. On the other hand, I would lose the capabilities of SQL server 2005 with the xml data type. I didn’t go down this path.


2)  Use a stored procedure instead of an updategram

Hmm – I didn’t know if a stored procedure would be an alternative solution considering the updategram doesn’t accept an xml data type. I followed the process again of adding a generated item, and this time I selected a stored procedure instead of an updategram.


.. And works like a charm J


Interestingly enough, the schema generated by BizTalk is a string data type for the xml field (Table – File Exception)!




I created my orchestration, updated the parameters and posted it to the SQL adapter. It works J







The Construct shape marked above creates my updategram message using a transform and an assignment shape.


Here is the code for the assignment shape using an xpath query  


xpath(InsertSqlRequest.query, “/ReceiveFileRequest/FileException”) = fileExceptionMsg.OuterXml;



Note: View this post here if you end up getting an encoding error by the SQL adpater.

Happy Coding J

Read Full Post »

Older Posts »