Thursday, April 1, 2010
Concurrent connections to SQL server or SQL express
It is a myth that SQL server or SQL express supports only 5 concurrent connections. There is some history behind it. Microsoft came up with MSDE engine to overcome limitations of popular Jet database engine. The initial version of MSDE engine could allow maximum 5 concurrent connections as the performance detoriorates if more than 5 concurrent connections are made to the MSDE database engine. Governor component in MSDE engine used to control the maximum connections.
The latest versions of SQL server (I guess SQL 2000 onwards) and SQL express does not have governor component. So now what limits the concurrent connections is now how the connection is made, for how much time and how it is used.
Saturday, March 20, 2010
CoCreateInstance returns CO_E_SERVER_EXEC_FAILURE (0x80080005) for ATL service created using Microsoft Visual Studio 2008
Create an ATL service project using Microsoft Visual Studio 2008. If you try to create instance of an object which is hosted by the service, CoCreateInstance returns error 0x80080005. The error means server execution failed.
It took lot of time to resolve this error and was quite frustrating as the error message is generic and does not give any clue about what could have gone wrong.
I tried creating a service which has one COM object and has a foo() method which does nothing and just returns. The CoCreateInstance was failing for this object as well with same error code.
While googgling for the error code, I came across an article which talks about a defect in Visual Studio 2008 wizard generated registry files. http://blogs.msdn.com/jigarme/archive/2008/05/08/cocreateinstance-returns-0x80080005-for-visual-studio-2008-based-atl-service.aspx
The APPID entry is missing from the wizard generated .rgs file. The error got fixed after adding the APPID entry in the .rgs file
ForceRemove {9ACB97C6-4492-40E8-A1BD-51DFE8962E92} = s 'CMyObject Class'
{
ProgID = s 'ATLComService.CMyObject.1'
VersionIndependentProgID = s 'ATLComService.CMyObject'
ForceRemove 'Programmable'
LocalServer32 = s '%MODULE%'
val AppID = s '%APPID%'
'TypeLib' = s '{E423A7DE-58C7-4535-A864-395DCEDE941F}'
}
Saturday, March 6, 2010
GetRecordInfoFromTypeInfo and GetRecordInfoFromGuids returns E_INVALIDARG if COM structure contains a GUID member field
To create SAFEARRAY of custom data types, you need to get the IRecordInfo pointer to the structure and pass it to SafeArrayCreateEx. You can get IRecordInfo pointer to the custom structure by calling either GetRecordInfoFromTypeInfo or GetRecordInfoFromGuids API.
Both of these API returns E_INVALIDARG if the sturcture contains member of type GUID. One way to workaround this problem is to convert GUID as BSTR.
This is a defect in Microsoft Visual Studio 2008 and hopefully will get fixed in next versions. Link to the microsoft page for same. https://connect.microsoft.com/VisualStudio/feedback/details/380266/getrecordinfofromtypeinfo-returns-e-invalidarg-if-a-com-structure-contains-a-guid-field
Monday, June 29, 2009
Running SQL service as console application
1. Stope SQL server service.
2. Start sqlserver.exe in console mode using following command
start /realtime sqlserver.exe -c -s YourInstanceName. Omit -s if you are testing with default instance
3. Pass command line parameter to enable trace flag for e.g. to trace event 3505 pass 'T3505'.
You must switch to the appropriate BINN directory for the instance at a command prompt before starting sqlservr.exe. For example, if Instance1 were to use \mssql$Instance1 for its binaries, the user must be in the \mssql$Instance1\binn directory to start sqlservr.exe -s instance1.
SQL server error log file locationSQL 2008 and 2005-> Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG and ERRORLOG.n files.
Wednesday, June 17, 2009
Easing The Pain Of WCF Debugging
WCF error: System.ServiceModel.CommunicationException: The socket connection was aborted
System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host
This error was very annoying and there was no clue what is going wrong. While googling for this, I came across some posts which talked about this issue. Every WCF channel has a receive timeout whose value is picked up from the app.config file when you add proxy for the service. If there is no activity during this timeout then WCF closes underlying socket and so further call on the channel throws Communication exception.
To resolve this issue, set the receive timeout to appropriate value at both client as well as server endpoints. You can use 'infinite' keyword to suggest WCF to use TimeSpan.MaxValue value. 'infinite' keyword is not recognized by Visual Studio editor and would show error for that which can be safely ignored. Another way to set infinite timeout is programmatically. At both endpoints (i.e. at client and server) set the endpoint's receivetimeout propery to TimeSpan.MaxValue.
Below is good posts on the same issue -
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/06cb1522-31f0-4ce3-85f0-02656228a8e1/
Wednesday, March 4, 2009
Log truncation fails on SQL 2005 and SQL 2008 server
http://msdn.microsoft.com/en-us/library/ms186865.aspx.