Monday, October 15, 2007

How to uninstall SQL 2005 if it's missing in Add/Remove Programs


First of all - here is the support KB article.
In my case - I was unable to uninstall SQL 2005 even manually from the command line (ArpWrapper was ceasing to work, displaying some "Registry Enumeration Failed" error and uninstalling components with MsiExec using their GUID's listed in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall just didn't worked).

I was able to do it by uninstalling SQL components manually with Microsoft Windows Install Clean Up utility (do it in order, specified in KB article).



Wednesday, October 10, 2007

How to create WCF service proxy without publishing mex endpoint #2


Important update to my previous article: if your service is defined inside of a namespace - you must specify the namespace using /serviceName option during the 1st step (WSDL and XSD creation).
Updated step #1 example:
svcutil /serviceName:MyNamespace.MyService MyServiceSvc.exe /reference:SomeReference.dll
If you'll miss specification of the namespace - resulting proxy code would be wrong (including even endpoing binding defintion).

Internet Explorer cannot open the Internet site - Operation aborted


I was affected by this issue and it took me some time to figure out what's the reason of it (in my case it was quite tricky). Generally - the reasons causing this error in IE are quite known. (Here are some for your reference :)

In my case it was a completely different story - it was caused by few IE DOM implementation bugs. Consider you have code on the IE client side that parses page body nodes and then removes them:

while (body && body.hasChildNodes()) {
var node = body.firstChild;
// ... app logic
body.removeChild(node);
}


Now consider that body content is created by Response.Write() on the server side (I write down some context in <p>...</p> paragraphs sections).
My application was working as a blaze, but occasionally I was getting "Internet Explorer cannot open the Internet site - Operation aborted" in IE. In Firefox it was never happen.
After some research I narrowed down the reason to the fact that body context is created by Response.Write and then I catched up what the problem was - it was related to the fact that on the server side I was writing body nodes in 4 steps:
1) ‘<p>’
2) app-specific content
3) ‘</p>’
4) Flush() output.

So - sometimes on the client side the code was running while paragraph weren't fully formed (e.g. only starting <p> was written).
In this case body.hasChildNodes() still returns true (IE bug #1) and body.removeChild(node) will cause "operation aborted" (IE bug #2).
As I noted - it's IE-specific and not happens in other browsers.

Fortunatelly - I had Response() bufferring turned off at the server side - o/w above problem would still happen, but with much lower frequency, making it very difficult to track it down.
The solution, as you may guess, is to write whole node at once on the server side...

Wednesday, September 19, 2007

.NET 3.5 Beta 2 - no LINQ performance improvements?


     Today I've got a comment on my post where I compared performance of LINQ vs. DAAB vs. ADO.NET, saying that I should repeat my test with .NET Framework 3.5 beta 2. Indeed there are a lot of posts about performance improvements introduced in it, so I've rushed and repeated my test, compiling it in Microsoft Visual Studio 2008 Beta 2, targeting .NET 3.5 beta 2.
     Not sure that proverb "no news - good news" is correct in this case, but - well - no news. I mean that performance results are absolutely the same - LINQ is about 30% slower than raw ADO.NET (4.28 ms per call for ADO.NET vs. 5.51 ms per call for LINQ). Also, using LINQ rather than ADO.NET makes application much more CPU intensive (something like ~20% of CPU intensity with LINQ vs. ~2% of CPU intensity with ADO.NET - difference of order of magnitude!). You may see screenshots below.

Timing results


CPU Intensity.(First third - ADO, second - DAAB, third - LINQ.)

So it seems to me that there are no significant performance improvements, unless there is something fundamentally wrong with my tests (check code here).

     Yet - I want to develop here something I've mentioned in my previous post. This additional performance cost doesn't mean "don't use LINQ". You'll probably never will get to performance incur of 30% in the real project. In the real life scenario you'll never abuse your DB by shooting thousands of SP calls in a batch, without doing something with results. There is always some business logic around, some DAL, some timings, etc - so the performance costs are never so high and they will be spread around evenly, rather than composed into a performance-loss peak. Also - mind that LINQ greatly improves coding productivity, decreases amount of code and project complexity. This means that developers would spend less timing coding and the costly thing for the project is the developer time. In the very worst case - profile your application to find the bottlenecks of 20:80 rule and use ADO.NET in critical sections of your code. And buy quicker CPU - they are cheap today :) ...

P.S.
     Few links to related articles:


Sunday, August 19, 2007

How to give alias to the SQL Linked Server


There are no problems to add SQL linked server to the specific host running it. But what if you need to give it an alias, rather than use hostname as linked server name?
Here is how to do it:
1) Step 1:
• In SQL Server Management Studio open Linked Servers and then 'New Linked Server'.
• Inside of appeared wizard – Select the General tab.
• Specify alias name in "Linked server" field.
• Select SQL Native Client as provider.
• Add sql_server in "Product Name" field (that's the magic).
• In "Data Source" – specify name of the host to be used as linked server.
2) Step 2:
• In Security tab – specify proper security options (e.g. security context)
3) Step 3:
• In Server Options tab – put "Data Access", RPC, "Rpc Out" and "Use Remote Collaboration" to be true.
4) Step 4:
• Enjoy.

How to create WCF service proxy without publishing mex endpoint


Some time ago I needed to create WCF service proxy, while I don't wanted to expose and publish MEX endpoint for it (and then generate the proxy from its wsdl). Strangely, but I didn't found any clue on how to do it in the Google depths. Even MSDN articles (1 and 2) devoted to the SvcUtil doesn't mention it in a straightforward way. Here is how to do it:

1) Create WSDL and XSD definitions for your service. Use following command:
svcutil /serviceName:MyService.MyServiceClass MyServiceAssembly.exe /reference:MyServiceContracts.dll
(You'll need to reference additional assemblies related to the service, like I did with MyServiceContracts.dll)

2) Generate proxies and corresponding client WCF configuration in .config file:
svcutil *.wsdl *.xsd /language:C#

Wednesday, August 15, 2007

In order to add an endpoint to the service MyService, a non-empty contract name must be specified.


Are you getting InvalidOperationException while creating ServiceHost for your service and getting message in style of "In order to add an endpoint to the service 'MyService', a non-empty contract name must be specified."? the probable reason is that you've missed contract definition in one of it's endpoints. Go to the endpoints list in your .config file and check that each endpoint has 'contract="MyContracts.IMyInterface"' tag.