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

Saturday, December 30, 2006

START

Hello! I am a C# programmer just like you are. My primary professional interest is software development (Requirements engineering, process, solution engineering … Whole thing).

I’m creating this blog as a convenient tool to post all the small things which I have used during software development.

After some time I have found that it’s difficult to remember exact procedure which I have already used to solve some problem. Let me mention one example. Recently I have encountered situation with web application using Microsoft rsweb:ReportViewer component on closed-down network. Closed down network is the network which can’t access internet. When the user clicks on print link for the first time, rsweb:ReportViewer component is initiating installation of the RSClientPrint ActiveX control in order to provide print functionality. This is automated process and it works just fine if you have Internet connection. The RSClientPrint control is downloaded and installed without any intervention from the user. If you don’t have internet connection, situation is quite different. You need to manually copy some files to specific folders in order to provide this functionality. As I already mentioned it’s easy to forget which files, from where and where to copy and in matter of fact I’m not remembering this things at all. This is why am I starting this blog.

Please if you think that some of my postings are having errors, don’t be lazy, type the correct procedure and please explain what was the error I my procedure.

So let’s start posting!