Search This Blog

Sunday, August 19, 2012

WCF Base Address error on Windows Vista

I am sure its not only me but many of you have encountered an unusual error when you first started an instance of a WCF Host application through Visual Studio on Windows Vista, the error will look something like this below

{"HTTP could not register URL http://+:49779/WcfServiceLibraryNorthwind/NorthwindService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)."}

Since vista's security is not exactly like old windows, so the owner of an HTTP namespace (in this case the administrator) will have to delegate that ownership to another user, so the command would be something like this below


"netsh http add urlacl url=http://+:portNumber/ user=MYMACHINE\UserName"

i.e as below in my case
netsh http add urlacl url=http://+: 49779/ user=KAUSHIK-PC\Kaushik

*On success, you will get a message like below
URL reservation successfully added

** please open the command shell "As Administrator", otherwise you will get an error as below 

Url reservation add failed, Error: 5

Tuesday, October 4, 2011

WebGrid Control Issues

If you are using web grid third party control in any of your applications please make sure to use it for the exact version of ASP.NET for which it was built for. Suppose if say you have a Webgrid to be used for an ASP.NET 1.1 application and if my mistake your default Website or your virtual directory has a version of ASP.NET as 2.0, then the webgrid will throw error like the datasource or memory used to access data from grid is corrupt and that is basically because the other version wp might not have access to the webgrid datasource.

Monday, September 12, 2011

Android app on windows using Eclipse

First all please go through this blog which guides developers like me who are basically .NET developers but having an interest on building Android application using windows platform.


http://www.caffeinedi.com/2010/07/03/beginning-google-android-development-for-net-developers-part-1/

The blog post will guide anyone on how to setup the environment and run your first app, but I want to highlight some of the issues I faced and which are quiet common and resolutions/work around those issues. First of all the 4 things that needs to be setup are


1. Java Development Kit (JDK) 6 – self-explanatory; the Java runtime and development libraries.


2. Eclipse – an IDE (integrated development environment) for Java and other languages.   If you don’t have it installed, grab the Eclipse IDE for Java Developers version, which will suit the needs of this tutorial.  The Windows download doesn’t contain an installer, so extract the ZIP in an accessible location, such as D:\eclipse.


3.Android Software Development Kit (SDK) – The heart of Android development.  This provides all of the necessary tools and libraries required to build applications for the Android platform.  Extract it to an accessible location on your hard drive and run the setup executable, which will download and install a set of components.


4.Android Development Tools (ADT) Eclipse Plugin – This plugin adds Android-specific development tools and project templates to Eclipse.  Instead of a separate download, it installs within Eclipse – you can follow the instructions here to get it installed.


ISSUE 1 At step 3, when you try to run the executable to install Android SDK, then that might give errors because it might not be able to detect the JDK. Instead of cancelling the installation, just click "Previous" button and go the previous screen and then "Next" button ,it will detect it this time for sure.


ISSUE 2 To install the ADT as in Eclipse plugin, follow the steps below to first download it as a plugin
1. Start Eclipse, then select Help > Install New Software....
2. Click Add, in the top-right corner.
3.  In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following   4. URL for the Location:

    https://dl-ssl.google.com/android/eclipse/

    Click OK

    Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of    "https" (https is preferred for security reasons).
    In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
    In the next window, you'll see a list of the tools to be downloaded. Click Next.
    Read and accept the license agreements, then click Finish.

    Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
    When the installation completes, restart Eclipse.



ISSUE 3 After creating your first Android virtual device, when you try to run the application, you can get an error like 
Emulator] PANIC: Could not open: C:\Documents and Settings\UserNAme\.android/avd/Android2.2.ini
This happens because if your Android SDK location is in any other location than C drive, the eclipse tool will not be able to locate that folder .android, so the solution would to look for the folder *.android and copy it over to the location sorted by the eclipse tool. In my case, I copied the folder .android from a location in my D: drive to C:\Documents and Settings\UserNAme\.android.
ISSUE4 While launching the new emulator, you might again get an error like
 Emulator] invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
 Emulator] Hint: use '@foo' to launch a virtual device named 'foo'.
 Emulator] please use -help for more information



To get around this issue change the SDK location path in eclipse to D:\PROGRA~1\Android\android-sdk for a 32 bit machine or change to D:\PROGRA~2\Android\android-sdkfor a 64 bit machine if your SDK installation is on D: drive or else the drive accordingly. 


This issue is because of the fact that eclipse will not be able to SDK location if SDK location contains any spaces.

Sunday, July 31, 2011

Creating a linked Server on SQL Server

EXEC sp_addlinkedserver @server='GM', @srvproduct='',
@provider='SQLOLEDB', @datasrc='databaseIP,Port',
@catalog ='DBName'
EXEC sp_addlinkedsrvlogin 'GM', 'false', NULL, 'DBUser', 'DBPassword'

--The Query, Using the Server Database you are already in and your new linked server: GM--
SELECT
NUMBER,
DT_CREATED AS DATE_CREATED,
PRIORITY,
(SELECT COMPANY FROM GM.myDatabase.dbo.myTable WHERE ACCOUNTNO IN (SELECT TOP 1 ACCOUNTNO FROM GM.myDatabase.dbo.myTable WHERE Field1=(SELECT CUSTOMER_NUMBER FROM CUSTOMERS WHERE ID=ID_CUSTOMER))) AS COMPANY FROM MAIN_TABLE

Thursday, July 28, 2011

Another way to Pass list of parameters to SQL Server Stored Procedures


The following are the ways you could have solved

1) Passing inputs (all Ids at once) as a comma separated string
2) Since SQL Server 2005 is CLR compliant, you could have written a dll which could have performed the above task at a better performance rate

3) But third option is passing all the inputs as XML. And XML parsing may be complex but this approach will be far more efficient. Have a look at the code below

CREATE   PROCEDURE  SP_EMPLOYEES @ids xml   AS
    SELECT  E . EMPLOYEEID ,  E . MANAGERID ,  E . NAME
    FROM    TBLEMP E
    JOIN    @ids . nodes ( '/Root/Employee' )   AS  T ( Item )
      ON    E . EMPLOYEEID =  T . Item . value ( '@num' ,   'int' )
go
EXEC  SP_EMPLOYEES N '<Root><Employee num="1"/><Employee num="2"/>
                             <Employee num="3"/><Employee num="4"/></Root>'

Tuesday, July 12, 2011

Opening DTS packages on SQL Server 2005 Management Studio

For opening DTS packages on SQL Server Management for 2005 and above, you will have to install the following components
1. DTS component for Sql Server 2005 Client
2. Backward Compatibility
from the following link

http://www.microsoft.com/download/en/details.aspx?id=15748

The names of the MSIs will be something like this SQLSERVER2005_DTS.msi anf SQLSERVER2005_BC.msi.

When done with the above installation, please make sure that if you have multiple installations of SQL Server, in Environment variable->System Variables, the entry of SQL Server 2000 Tools should be before the latest version like below

C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;


Sharepoint 2010 on Windows 7

This url has the full instructions on how to go about this. http://sharepoint-2010-world.blogspot.com/2011/02/install-sharepoint-foundation-2010-on.html

Will try this once I am done with Windows 7 upgrade on my desktop. Also this site is helpfull
http://mkdot.net/blogs/zzl/archive/2008/06/18/install-vs-2005-2008-extensions-for-sharepoint-on-windows-xp-vista-os.aspx