Wednesday, August 12, 2015

Dell XPS 15z Windows 10 Upgrade

Dell hasn't yet announced support for Windows 10 on Dell XPS 15z laptops. But since I got the upgrade notification, I went ahead and upgraded. First of all, the upgrade wizard complained about Cypress track pad being not a compatible software. And I had to uninstall it. This was the only thing I had to do and the upgrade completed successfully. All existing soft wares including Sql server 2008 R2, 2012, Visual Studio 2012, 2013, 2015, MS Office etc worked perfectly fine. The only thing I missed was the Kaspresky 2015 antivirus, which was supposed to be upgraded before the Windows 10 upgrade. This was fixed by re-installing the antivirus software. Overall, the upgrade was a pretty smooth and a pleasant experience. 

Friday, January 27, 2012

System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'


System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

This started happening after I enabled WCF HTTP and Non-HTTP Activation under Micosoft .NET Framework 3.5.1.

Fix : - run ASP.Net regiis again from 4.0. (Run VS 2010 command prompt and execute aspnet_regiis -i).








Thursday, October 29, 2009

Site Under Maintenance with ASP.Net 2.0

If you have worked with deploying websites onto production/test environments, you might have wanted to show a 'Site Under Maintenance' or a similar message to all those who tries to access the website. To achieve this, people used to resort to all kinds of  setups ranging from HttpModules to setting up a html page as default page of the application.

Now in Asp.Net 2.0 onwards we have a simple way of acheiving this. Just put a file NAMED app_offline.htm in the root folder of the application and : voilĂ !! all new requests will be redirected to that html page. 

To revert back, just rename the file to some other name. Neat & clean. 


[Edit 04 Aug 2010 ] This might not be good idea as ASP.Net responds with a 404 http code. Ideally it should have been 200.

Monday, October 12, 2009

Simple way to check time consumed by a piece of code using stopwatch class

TimeSpan ts;
string elapsedTime;
System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
//DO SOME LENGTHY OPERATION
ts = stopWatch.Elapsed;
elapsedTime =
                    String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                    ts.Hours, ts.Minutes, ts.Seconds,
                    ts.Milliseconds / 10);
 stopWatch.Reset();
 stopWatch.Stop();

Use XML with SQL

Declare @doc xml

set @doc ='


'
Declare @handle int

Exec sp_xml_prepareDocument @handle output, @doc

Select ImageName, date From openXML(@handle, N'/r/i') with (ImageName varchar(20) 'n', date datetime 'm')
Select ImageName,date From openxml(@handle,'/r/t') with (ImageName varchar(20) 'n', date datetime 'm')

Exec sp_xml_removeDocument @handle

Thursday, July 23, 2009

Executing a stored procedure with output parameter doesnt return any value.

When you use a DataReader object to read data from SqlServer, the parameter passed in as output parameter doesnot get assigned even after excuting the reader.

Solution:- Close the DataReader and your value will get returned.

Reason:- The output parameter is returned at the end of the data stream when you use a DataRader.

Reference:- http://support.microsoft.com/kb/308621

Wednesday, April 8, 2009

Sql Server 2005 Linked Server Scripting issue

I generated the 'CREATE' script of a linked server in my DB and got the following script

EXEC master.dbo.sp_addlinkedserver @server = N'MYSERVERNAME', @provider=N'SQLNCLI', @datasrc=N'MYINSTANCENAME, @catalog=N'SOMENAME'

I dropped the same and tried to add it with the above script and it gave me the error

Msg 15429, Level 16, State 1, Procedure sp_addlinkedserver, Line 42
'(null)' is an invalid product name.

Solution :- Add the product name also in the sp parameters.

An sp_helptext on the sp showed this:-

create procedure sys.sp_addlinkedserver
@server sysname, -- server name
@srvproduct nvarchar(128) = NULL, -- product name (dflt to ss)
@provider nvarchar(128) = NULL, -- oledb provider name
@datasrc nvarchar(4000) = NULL, -- oledb datasource property
@location nvarchar(4000) = NULL, -- oledb location property
@provstr nvarchar(4000) = NULL, -- oledb provider-string property
@catalog sysname = NULL -- oledb catalog property
as


etc etc ...

The Script Linked Server as Create To command somehow missed the @srvproduct parameter.

So the modified sql statement will be

EXEC master.dbo.sp_addlinkedserver @server=N'MYSERVERNAME', @srvproduct=N'MSSQLSERVER', @provider=N'SQLNCLI', @datasrc=N'MYINSTANCENAME, @catalog=N'SOMENAME'

Wednesday, March 4, 2009

Regex for matching relative URLs

This Regex will match the following Relative URLs
REGEX
-----
^(/[a-zA-Z0-9]+)+(\.[a-zA-Z]{2,4})((\?\w*=?\w*)(\&\w+=\w+)*)?$

URLs
----
/folder1/page.ax
/folder1/page.php
/folder1/folder2/page.aspx
/folder1/page.aspx?qstring1=value1 (likewise n number of query strings)

Will not match

/folder1?/page.aspx
/folder1/page.aspx?=value1
/folder1/page.aspx?qstring1=value1?qstring2=value2


^(/[a-zA-Z0-9]+)+(\.[a-zA-Z]{2,4})((\?\w*=?\w*)(\&\w+=\w+)*)?$

Friday, February 27, 2009

LINQ ERROR

I was working with a LINQ sample and stumbled upon the following error.
"The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments"

XML file I was using :-


Code used :-


//The application is a ASP.net page
XDocument xDoc = XDocument.Load(HttpContext.Current.Server.MapPath("Persons.xml"));

IEnumerable queryNew = from e in xDoc.Descendants("Person")

select new Person{
FirstName = e.Element("FirstName").Value,
LastName = e.Element("LastName").Value,
Salary = Convert.ToInt32(e.Element("Salary").Value)
};


Solution :- IEnumerable is present in both System.Collections.Generic and System.Collections name spaces. The query returns a generic collection. So in this case We should use System.Collections.Generic. So when I provided a "using System.Collections.Generic;" on top of the page, it did the trick for me.

Wednesday, December 10, 2008

Check box list validation

The following javascript will validate that atleast one checkbox is checked in a checkboxlist . And if a checkbox named 'other' is checked , it will check that a textbox that is next to it is not empty .


How to get the domainname of an ASP.Net application

If the application URL is something like www.myDomain.com/home/homepage.aspx , to get the http://www.mydomain.com/ part from it , we can use the following
(1)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.DnsSafeHost
or
(2)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.Host

Tuesday, December 9, 2008

My first post...

As developers we come accross many issues while coding . I was thinking of writing down some of the solutions that I came accross , as blog entries so that it might help others who face the same kind of issues.
Better late than never ;) ..