Monday, January 29, 2007

Installing Windows Service developed with .NET 2.0

Problem

How to install windows service developed with .NET 2.0 without setup project?

Solution

  1. Create your service . Project output is .exe. We will use Project1Service.exe as reference to project output during this text.
  2. Run command prompt
  3. You need to execute following command InstallUtil Project1Service.exe, but take care. If you have .NET 1.1 and .NET 2.0 installed on your computer you have two versions of InstallUtil as well! If you try to install service, written in .NET 2.0, with InstallUtil from .NET 1.1 you will encounter error:

    Microsoft (R) .NET Framework Installation utility Version 1.1.4322.573
    Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

    Exception occurred while initializing the installation:
    System.BadImageFormatException: The format of the file Project1Service.exe' is
    invalid..

    You need to locate correct version (try looking at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ path)

    Running this verision of the InstallUtil will produce output similar to the following:

    Microsoft (R) .NET Framework Installation utility Version 2.0.50727.42
    Copyright (c) Microsoft Corporation. All rights reserved.

    Running a transacted installation.
    :
    The Commit phase completed successfully.

    The transacted install has completed.

Friday, January 19, 2007

Using SqlMembershipProvider aspnet_Users_DeleteUser stored procedure

Question: How to use SqlMembershipProvider aspnet_Users_DeleteUser stored procedure?
Answer:
Here is script
1. USE [DataBaseName]
2. GO
3.
4. DECLARE @return_value int,
5. @NumTablesDeletedFrom int
6.
7. EXEC @return_value = [dbo].[aspnet_Users_DeleteUser]
8. @ApplicationName = N'/',
9. @UserName = N'UserName',
10.@TablesToDeleteFrom = 15,
11.@NumTablesDeletedFrom = @NumTablesDeletedFrom OUTPUT
12.
13.SELECT @NumTablesDeletedFrom as N'@NumTablesDeletedFrom'
14.
15.SELECT 'Return Value' = @return_value
16.
17.GO


Comment Let’s look at @TablesToDeleteFrom parameter. This parameter is a bit mask that specifies which provider database tables the user should be deleted from. The allowed values are:

Value Bit mask Table to delete from
1 0001 aspnet_Membership
2 0010 aspnet_UsersinRoles
4 0100 aspnet_Profile
8 1000 aspnet_PersonalizationPerUser
15 1111 Delete from all tables + aspnet_Users

and combinations!


aspnet_Users_DeleteUser uses a database transaction to ensure that the deletions are performed in whole or not at all.


At first it is bit confusing! You will set a @TablesToDeleteFrom parameter value to 15 and return value @NumTablesDeletedFrom can be just 2 (Deleted from aspnet_Membership and aspnet_Users) !


If you are using SqlMembershipPriver you will find MSDN article http://msdn2.microsoft.com/en-us/library/aa478949.aspx very interesting.

Wednesday, January 10, 2007

Reporting services error "Logon failed. (rsLogonFailed)

Problem

I have reporting services running on my development machine (Windows XP SP2). After I change my system password reporting services reports are not rendered. Error message shown is “Logon failed. (rsLogonFailed) …”.

Solution

You need to change Execution Account for you Reporting services installation.

  1. Run Reporting services configuration manager
  2. Select Execution Account.
  3. Enter and verify your password!

Thursday, January 4, 2007

Using print feature of ReportViewer control in locked-down networks

Problem:

When user click on the print button of the ReportViewer control toolbar for the first time, printing is available after installation of RSClientPrint ActiveX component downloaded from Internet.

In locked-down networks internet connection is not available and installation couldn’t be done.

Solution:
  1. On the computer with MS ReportingServices installed locate RSClientPrint.cab (tip: Use search ! ) Beware: Use appropriate version of cab file!
  2. Open RSClientPrint.cab with WinZip or clone an extract files to C:\WINDOWS\Downloaded Installations (C:\Windows is my Windows Home) in new folder RSINSTALL, on the client machine.
  3. Start the command prompt
    Navigate to C:\WINDOWS\Downloaded Installations\ RSINSTALL and manually register RSClientPrint.dll with regsvr RSClientPrint.dll
    The printing feature is now enabled