Saturday, December 26, 2009

Error: "The project type is not supported by this installation."

There could be many cases that cause this error. One such case is when you try to open/migrate web project application developed in Visual Studio 2003 in the Visual Studio 2005. The reason being VS 2005 does not come with web project template because VS 2005 comes with new web application development & compilation machanism that is called website model. for more details click here.

So to solve this problem you will have to install following updates on your machine.

1. Microsoft Visual Studio 2005 - Update to Support Web Application Projects
2. install Microsoft® Visual Studio® 2005 Team Suite Service Pack 1

Note - To fully enable Web Application Projects in Visual Studio 2005, you will have to install both these updates.

Reference- http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx

Saturday, December 5, 2009

Redirecting Assembly Versions

How to redirect an application to run against newer version of an assembly.

An application configuration file, machine configuration file, or a publisher policy file can redirect one version of an assembly to another. You can use the .NET Framework Configuration tool (Mscorcfg.msc) to redirect assembly versions at both the application level and the machine level, or you can directly edit the configuration file.

Note: You cannot redirect versions for assemblies that are not strong-named. The common language runtime ignores the version for assemblies that are not strong-named.

Redirecting Assembly Versions Using Publisher Policy

Vendors of assemblies can state that applications should use a newer version of an assembly by including a publisher policy file with the upgraded assembly. The publisher policy file, which is located in the global assembly cache, contains assembly redirection settings. Vendors use publisher policies only when the new assembly is backward compatible with the assembly being redirected.

You can bypassing Publisher Policy by using following tag in the app.config/web.config files.

< publisherPolicy apply="no" >

Redirecting Assembly Versions through App.config/Web.config files

Specify information for an assembly by placing information for each assembly inside a element. The element contains information that identifies an assembly. You can have more than one element in the configuration file, but there must be exactly one element in each element. To redirect one version to another, use the element. The oldVersion attribute can specify either a single version, or a range of versions. For example, specifies that the runtime should use version 2.0.0.0 instead of the assembly versions between 1.1.0.0 and 1.2.0.0.

Example:

< configuration >
< runtime >
< assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
< dependentAssembly >
< assemblyIdentity name="myAssembly" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" / >
< !-- Assembly versions can be redirected in application, publisher policy, or machine configuration files. -- >
< bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/ >
< / dependentAssembly >
< dependentAssembly >
< assemblyIdentity name="mySecondAssembly" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" / >
< !-- Publisher policy can be set only in the application configuration file. -- >
< publisherPolicy apply="no" >
< / dependentAssembly >
< / assemblyBinding >
< / runtime >
< / configuration >

Note: The elements are order-sensitive. You should enter assembly binding redirection information for any .NET Framework version 1.0 assemblies first, followed by assembly binding redirection information for any .NET Framework version 1.1 assemblies

Reference: http://msdn.microsoft.com/en-us/library/7wd6ex19(VS.71).aspx

Tuesday, June 2, 2009

Publish Website: Access to the path ...\App_WebReferences.compiled' is denied.

This error sometimes comes during publishing website that implements impersonation. When impersonation setting is made in the web.config file and the impersonate user dose not have access permission on the temp directory, this error likely to come. Although I don’t understand why impersonate user needs access permission on temp directory because during publishing website is precompiled and copied in the given location.

Anyways the solution that worked for me is that I commented the impersonation setting in the web.config file and then published it after publishing succeed I uncommented the settings from the web.config file in the published folder.

Friday, May 8, 2009

HTTP Modules Versus Global.asax Files

You can implement much of the functionality of a module in the application's Global.asax file, which enables you to respond to application events. However, modules have an advantage over the Global.asax file because they are encapsulated and can be created one time and used in many different applications. By adding them to the global assembly cache and registering them in the Machine.config file, you can reuse them across applications. For more information, see Global Assembly Cache.

The advantage of using the Global.asax file is that you can handle other registered events such as Session_Start and Session_End. In addition, the Global.asax file enables you to instantiate global objects that are available throughout the application.
You should use a module whenever you must create code that depends on application events, and when the following conditions are true:
# You want to re-use the module in other applications.
# You want to avoid putting complex code in the Global.asax file.
# The module applies to all requests in the pipeline (IIS 7.0 Integrated mode only).
You should add code in the Global.asax file whenever you must create code that depends on application events and you do not have to reuse it across applications. You can also use the Global.asax file when you have to subscribe to events that are not available to modules, such as Session_Start.

Global.asax file is derived from HttpApplication class and it does not implement IHttpModule interface like custom modules. If you are not going to use your custom module in any other application or don’t have complex logic than you should use Global.asax instead of creating custom modules.
You can have multiple modules in your web application implementing same events. Modules are called in the sequence they are added in the web.config file. With in a module events are called in following sequence:

BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
PreRequestHandlerExecute
PostRequestHandlerExecute
ReleaseRequestState
UpdateRequestCache
EndRequest
PreSendRequestHeaders
PreSendRequestContent
Error

Event calling sequence in multi module Scenario:
Suppose there are Global.asax and 2 custom modules namely Module.cs and Module1.cs in an application. Custom modules are added in web.config in following order.

< httpModules >
< add name="MyModule1" type="MyModule1" />
< add name="MyModule" type="MyModule" />
< /httpModules >

And all of them are handling first 3 event in the above given list – BeginRequest , AuthenticateRequest, AuthorizeRequest.

The sequence of event call will be as follows:

Application_Start - Global.asax
Init - Global.asax
BeginRequest - MyModule1
BeginRequest - MyModule
BeginRequest - Global.asax
AuthenticateRequest - MyModule1
AuthenticateRequest - MyModule
AuthenticateRequest - Global.asax
AuthorizeRequest - MyModule1
AuthorizeRequest - MyModule
AuthorizeRequest - Global.asax
Session_Start - Global.asax
Page_Load

What is the difference between ETL tool and OLAP tool?

ETL:
Extract, Transform and Load. This is a product to extract the data from multiple/single source transform the data and load it into a table, flat file or simply a target.
There is a quite a bit competition in the market with regard to the ETL product as well as the OLAP products. These tools would definitely be widely used for data load and data analysis purpose.
ETL tools in market

1 INFORMATICA-- univeral tool good market
2 ABINITO -- fastest loading tool very good market
3 DATASTAGE-- difficult work no good market
4 BODI-- good market
5 ORACLE WAREHOUSE BUILDER-- good market

ETL Tools is for Extracting source data, Transforming as required and Loading into DW. it is first part of DW. Now large fact and dimension tables are in DW. If you have to generate crosstab report from these tables, it will take very long time. So these DW tables are transformed into Cubes and stored in OLAP Server. Any Report Generation, Analysis is done on these... Cubes are having pre aggregated values and hence Report Generation will be much faster.

OLAP:
Its an online analytical processing tool. There are various products available for data analysis. Like Hyperion which is a Business Intelligence (BI) and Business Performance Management (BPM ) Tool like Brio, Business Objects and Cognos etc. Its the market leader in Financial, Operational and Strategic Planning. It has applications for Planning, consolidation, scorecarding, reporting, dashboards, Analysis, Workspace, Master Data Management and Foundation.

The Difference between the two:
There are only 2 ways available to get data from a datawarehouse or a database.one is using sql statement and other method is using an OLAP tool(ex:cognos, business objects.....)So Hyperion is an example for a OLAP tool. ETL is a process of Extracting data from a source systems(a system where client's transactional business information resides) and performing business logic(applying TRANSFORMATION rules) on the collected source information(business logic depends on business requirements), and LOADING the precise data into a warehouse(probably a relational database). OLAP comes into picture after ETL developers design the warehouse........by using olap tools a business user can generate standard reports(without having sql knowledge he can do this)

How to configure application services in asp.net

Here I am not going to explain what is application service in asp.net, for that you can see my post -
Using Web Parts with SQL Server 2000/2005.

Configuring application services in your asp.net application is a two step process:

1. Configure database objects that will hold application services data.
2. Configure providers that will provide access to application services data from the database.

For Configure database objects use following sql script that will create database & its objects(tables, Sps) for storing application services objects.
These are found at :\WINDOWS\Microsoft.NET\Framework\v2.0.50727

InstallCommon.sql
InstallMembership.sql
InstallPersonalization.sql
InstallProfile.sql
InstallRoles.sql

Make sure you run "InstallCommon.sql" script first as it creates database before running other scripts. By default database name is "aspnetdb" but if you want to change it, you can update InstallCommon.sql script.
These sql scripts are handy if you dont want to use all application services or you dont want to create separate database for it. In that case you can run any one or all script(s) depending upon the service you want to use on your application database. like if you want to implement only personalization then you just need to run "InstallPersonalization.sql" on your main database.

You can unstall these objects as well using following sql scripts.

UninstallCommon.sql
UninstallMembership.sql
UninstallPersonalization.sql
UninstallProfile.sql
UninstallRoles.sql

For example you may want to use only personization service not profile, membership and role service in that case there is no point to have other services configured in the application.
So you can run InstallCommon.sql followed by InstallProfile.sql sql scripts.
Note:- dont forget to change database name in the InstallCommon.sql sql script with the database in which you want to configure application service data objects.

You can do same thing using aspnet_regsql.exe utility as well using following command at the command prompt.

aspnet_regsql.exe -S < server name > -U < username > -P < password > -A < service code > -d < database name >

service code - all : all services
m : membership
r : role manager
p : profile
c : personalization
w : sql web event provider

For example if you have to add only profile service in your existing database, run following command at the command prompt:

aspnet_regsql.exe -S myserver -U user1 -P pass1 -A p -d mydb

Note:- replace server name, user name, password and database name with user's.

To remove profile service use -R in place of -A

Like:- aspnet_regsql.exe -S myserver -U user1 -P pass1 -R p -d mydb

----------------------------------------------------------

Second step is to configure providers in the web application.
Below is the code sample that can be added in the web.config file depending upon the application service you want to configure in your web application.

Provider's configuration in web.config file.

< !-- Connection string will point to the database that is configured to store application service data -- >
< connectionStrings >
< add name="SQLConnString" connectionString="Data Source=FN-WS282-D8;Initial Catalog=AppServices;Integrated Security=false; user id=sa; pwd=pass1" providerName="System.Data.SqlClient" />
< /connectionStrings >

< !-- Add following code for configuring personalization in the web.config file -- >
< webParts >
< personalization defaultProvider="SqlPersonalizationProvider" >
< providers >
< add name="SqlPersonalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< authorization >
< deny users="*" verbs="enterSharedScope" />
< allow users="*" verbs="modifyState" />
< /authorization >
< /personalization >
< /webParts >

< !-- Add following code for configuring profile in the web.config file -- >
< profile defaultProvider="SqlProfileProvider" >
< providers >
< clear />
< add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< properties >
< add name="Message" type="System.String" />
< /properties >
< /profile >

< !-- Add following code for configuring membership in the web.config file -- >
< membership defaultProvider="SqlMembershipProvider" >
< providers >
< clear />
< add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< /membership >

< !-- Add following code for configuring role manager in the web.config file -- >
< roleManager defaultProvider="SqlRoleProvider" >
< providers >
< clear />
< add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SQLConnString" applicationName="/" />
< /providers >
< /roleManager >

Thursday, April 23, 2009

Pass by reference to a Web Service

Few days back someone asked me if we can pass value by reference to a web method. I thought why would some one want to pass parameter's reference to a web method because parameter's reference will point to memory location in client machine whereas web method will be invoked on the server machine where that reference will be invalid.
Anyways, the reality is that you can pass value by reference to a web method if it allows so. In fact you can also create web method that will take "out" parameter.

In Web Methods parameters can be passed by reference using “ref” keywords just like any other method.
Like –
[WebMethod]
public void WebMethod2(ref int iparam)
{
iparam = iparam + 100;
}

And in the proxy class at the client end it is declared as below:

public void WebMethod2(ref int iparam)
{
object[] results = this.Invoke("WebMethod2", new object[] {iparam});
iparam = ((int)(results[0]));
}


Web Methods can also have “out” parameters.
Like -
[WebMethod]
public string WebMethod1(string str,out int iReturn)
{
string temp = "Hello " + str;
iReturn = temp.Length;
return temp;
}

And in the proxy class at the client end it is declared as below:

public string WebMethod1(string str, out int iReturn)
{
object[] results = this.Invoke("WebMethod1", new object[] {str});
iReturn = ((int)(results[1]));
return ((string)(results[0]));
}

Error: A name was started with an invalid character.

Sometimes when we try to browse our newly hosted website or web service, we encounter with this error. The reason is that we forgot to configure ASP.NET version in the IIS or selected wrong version when we were hosting it.

So now its time to correct this issue, follow these steps:

1. Open IIS management console.
2. Right click on the virtual directory of your web service and choose properties from the shortcut menu.
3. Now click on the ASP.NET tab and choose appropriate ASP.NET version from the dropdown.
4. Now click on Apply button to apply new setting and then click on OK button.

Now try again to access you website/web service, you should be able to do so…

Wednesday, April 22, 2009

Facts about Web Services

1. Web service class can have overloaded constructors (parameterized) but client can use only default parameter less constructor to instantiate web service object.
2. service constructor(s) can not be made web method using “WebMethod” attribute.
3. If web services is updated then the client needs to updated the web reference to get the changes reflected in the proxy class and if the change affecting any web method call in the client then client needs to be rebuilt after code change as well.
4. Web methods can have public, private, protected, internal and protected internal access modifiers but only public web method will be exposed to the client.
5. Web service class could be public or internal. [Class can not be declared as private, protected or protected internal].
6. Web method could be declared as virtual method.
7. Public class can not be derived from web service class as it lessens the accessibility of base web service class. But you can derive non public class.
8. Web service class can have non “[WebMethod]” functions as well.
9. Web service class can implement interface and declare implemented interface function as “[WebMethod]” so they can be exposed to clients.
10. Web Method can be declared as static but then it will not be exposed to client.
11. Web Service class can be declared as sealed class.

Tuesday, March 31, 2009

error: "The report server is not responding. Verify that the report server is running and can be accessed from this computer"

You may encounter this error when you try to browse reporting manager's home page. like...

http://localhost/Reports/Pages/Folder.aspx

Or when you try to browse report server. like...

http://localhost/Reportserver

It shows the following message:

The report server has encountered a configuration error. See the report server log files for more information. (rsServerConfigurationError)
Access to the path 'c:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\RSReportServer.config' is denied.

Reason:

Actually when you configure reporting servies on the machine, 2 virtual folders are created on IIS:

1. Reports - Sql Server Reporting Manager
2. ReportServer - Sql Server Report Server

These are mapped to the following physical location on the machine respectively

1. C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager
2. C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer

If these location do not have proper security permission for ASPNET or NETWORK SERVICES account then you may face above mentioned errors.
So to solve this issue just give the appropriate security permissions (like Read & Execute,List Folder Contents, Read) to ASPNET or NETWORK SERVICES account. If issue still persists make sure the above permissions are applied on RSWebApplication.config file on C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager and rsreportserver.config file on C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer location as well. You can give more permissions like write etc.

Tuesday, January 20, 2009

How to restart windows service from SQL Job?

There could be many reasons for this requirement which, I am not going to discuss in this post. Here I will explain how you can do it.
Now, suppose you want to create an sql job that will restart window service, it means window service will be stoped first and then started again.

Following are the steps to create sql job that will do it.

1. Open Microsoft SQl Server Management Studio than click on the SQL Server Agent under the Sql server where you want to create sql job.
2. Right click on the jobs folder under SQL Server Agent and choose New Job option from the short cut menu.
3. In the New Job window General page, name your job.

Now you will have to create 2 job steps, first for stopping the window service and another one for starting it again, for that:

4. Click on the Steps in the "Select a page" section to open Steps page.
5. Click on the "New..." button on the Steps page to create new step.
6. In the new job step window, give name to your step in the "Step Name" field.
7. Choose "Operating system (CmdExec)" option from the dropdown for the job step type.
8. Enter following command in the "Command" field.

net stop "< Windows Service Name >"

like - net stop "Terminal Services" to stop terminal service.

9. Click on OK button to complete the job step creation process.
10. Now repeate steps 5 to 9 for creating another job step for starting the window service. But this time the command would be as follows:

net start "Terminal Services"

11. Now choose the first job step from the job step list and click on edit button, the job step will open in a window.
12. Click on the "Advance" page and choose second job step for the "On success action" and "On failure action" from the respective dropdown controls and click on OK button.

Reason: If service is already stop than this job step will fail so we will start the service otherwise if service is running than it will be stopped successfully so we will start it again.

13. Now go to the "Advance" page for the second job step and choose "Quit the job reporting success" for "On success action" and "Quit the job reporting failure" for "On the failure action" from the respective dropdown control.

There are other settings like Schedules, Alerts, Notifications, Targets for the
SQL Jobs that you can set according to your requirement, I am not going to discuss them in this post.

14. Now click on the OK button on the New Job window to complete the job creation process.

Now you are ready to run your newly created sql job to test it.