Friday, 5 April 2013

Dot Net Framework 3.5 Not Installing on Windows 8? Fix it Now!





You may face a common problem while using Windows 8. Microsoft .Net Framework 3.5 is not installed with Windows 8. And several programs may ask you install this. And you can't install this from your PC. It will ask you to connect to the net and use Windows Update. 

By default Windows 8 comes with .Net Framework 4.5 and it doesn't include 3.5. When you try to install .Net 3.5 that you previously downloaded from web the you will see the following message. 




And you will get the same message while installing some some programs that is developed using .Net 3.5 platform. And you will not able to run those programs on your PC! This is a very bad job by Microsoft. A great trouble for Windows 8 users. 

But today you will get the solution. You've install this using command line. I mean you have to use Command Prompt. And surprisingly you Windows 8 DVD includes the .Net Framework 3.5! 

Method 1 (Offline Installation using cmd):
  1. Enter your Windows 8 Installation Disk on DVD Drive.
  2. Now run Command Prompt as Administrator. (Hint: Start > Type cmd > Now right click on Command Prompt and hit on Run as Administrator from the bottom)
  3. Now copy the following command and paste it in the command prompt window. Or type the following line in command prompt. Press Enter (To paste the command in command prompt, click the right button of mouse and select paste)
  4. Now .Net Framework will be installed within few minutes. 
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:h:\sources\sxs


Remember: h is the drive letter of DVD drive. Change it with your DVD drive letter. 


Method 2 (Online Method using Windows Update): 

If you follow all the instructions of method 1 you will be able to install .net 3.5 properly. But if there is any problem for example- you don't have DVD drive, or your Windows DVD doesn't contain it then you can install it directly from Windows Update option. More or less you've to download 200 MB data from internet. 

Follow the instruction below: 
Control Panel > Programs and Features > Turn Windows Features on or off > Mark the option .NET Framework 3.5 (includes .NET 2.0 and 3.0) > OK. 
Now you will see a window like the image above. Hit on Install This Feature. And make sure you're connected to the net. That's it.  


Installing a Windows language pack on Windows 8 before installing the .NET Framework 3.5 will cause the .NET Framework 3.5 installation to fail. Install the .NET Framework 3.5 before installing any Windows language packs.

Monday, 1 April 2013

System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.


Server Error in ‘/’ Application.


Security Exception

Description:

The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.

Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:
[SecurityException: Request for the permission of type
'System.Web.AspNetHostingPermission, System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.]
   System.Reflection.Assembly._GetType(String name,
Boolean throwOnError, Boolean ignoreCase) +0
   System.Web.UI.Util.GetTypeFromAssemblies(ICollection
assemblies, String typeName, Boolean ignoreCase) +201
   System.Web.UI.TemplateParser.GetType(String typeName,
Boolean ignoreCase, Boolean throwOnError) +323
   System.Web.UI.TemplateParser.ProcessInheritsAttribute(String
baseTypeName, String codeFileBaseTypeName,
String src, Assembly assembly) +10891548
   System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes
(IDictionary parseData) +365
Cause
The files were downloaded from the internet or an untrusted source.  Your computer/server are blocking them to help in protecting your computer.
Solution:


Right click on each file that you download and choose properties and Unblock.

image
Add the following to the system.web section of the web.config file.
Validate you have the correct .NET code base. You may have 4.0 code that is running as 2.0



Sunday, 17 March 2013

Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Title: SharePoint 2010 Error occurred in deployment step 'Retract Solution': Cannot start service SPUserCodeV4 on computer

Details: Building Sandboxed Solutions on SharePoint 2010 using Visual Studio 2010 Beta and encountered the error? Then make sure that the service Microsoft SharePoint Foundation User Code Service ( CA > System Settings > Services on Server ) is Started.

Thursday, 14 March 2013

Creating Full Text Index in SQL Server


Introduction

In this article we will see how to create a full text search index for SQL Server database for effective search. In so many cases we need to provide the search facility in our application. To provide searching facility within our local database we can use the greater feature provided by Microsoft SQL Server i.e. full text index.

Background

When we want to use the full text index service we need to start the service first else it will raise the errors. So let's start with how to start the service and use the Full text index step by step.

Step 1

Open SQL Server and create a new database with the following table for eg. Tbl_Search but keep in mind that the full text index only works on primary key or unique key containing tables.

Create Table Tbl_Search
(
Id Int Primary Key Identity(1,1),
Title Varchar(500),
[Desc]Varchar(max)
)

Insert some rows in the created table.

Step 2

Now we will create full text index on our database and table for providing search in table. So create the Full Text Catalog on our database by using following query.

CREATE FULLTEXT CATALOG FTSearch

In the query above we have created FullText Catalog with the name FTSearch.

Step 3

Now we will create full text index on our table Tbl_Search but for that we require the unique key id or primary key id so find the id of unique or primary key by using following command.

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

This command will display the all constraint names on tables present in our database from the output. Copy the Tbl_Search constraint name for creating a full text index on TblSearch.

CREATE FULLTEXT INDEX ON Tbl_Search


(Title, [Desc] LANGUAGE 1033)
KEY INDEX PK__Tbl_Sear__3214EC0700551192
ON FTSearch

In the above statement you can see we are creating a FullText Index on table name with a parameter; this parameter is nothing but the column name of the table on which we want to create the full text index and language 1033 denotes the language English.

Step 4

Now it's time to search the records in a specified indexed table. For that we can write the queries like below.

Select * from Tbl_Search Where Contains(Title,'Asp.Net')
Select * from Tbl_Search Where Freetext([Desc],'Asp.Net')

In the preceding queries you can see we have given a where clause with column name which is the column we want to search and what we want to search. The preceding queries retrive the rows of a table which contain ASP.Net in title column and the second query will retrieve the rows of ASP.Net in the desc column.

In some cases your queries gives an error like fdhost cannot be started. That means your FullTextIndex Service is not started; for that you have to first start the Demon Launcher for FullTextIndex service.

Step 5

For starting FullTextIndex service go to SQL Server Tool->SQL Server Configuration Manage->Service->FullTextSearch Demon Launcher if it is stopped then start this service for performing search operation with a contains and FreeText clause and restart the SQL Server instance.

Conclusion

In this way we can use the FullTextIndex on our database.







Note:


EXEC sp_fulltext_database 'enable'
EXEC sp_fulltext_database 'disable' 






 

Friday, 28 December 2012



Gridview Rows and Columns Value Calculation using Javascript

ex. Just i tried with Invoice application Demo.


   <script type="text/javascript">
      function multiplication(obj)
      {    
          
          var cell = obj.parentNode;               
          var per=obj.value*(0.1236);
          if(obj.value!="")
          {
            cell.parentNode.cells[cell.cellIndex + 1].getElementsByTagName("input")[0].value = per;
            //alert(obj.value*(0.1236));
            cell.parentNode.cells[cell.cellIndex + 2].getElementsByTagName("input")[0].value=parseFloat(obj.value)+parseFloat(per);
                 
       }  
        var gv = document.getElementById('<%=GridView1.ClientID %>');
            var Amount = 0;
            var tax=0;
            var total=0;
            for (var i = 1; i < gv.rows.length - 1; i++){
                if (gv.rows[i].cells[1].childNodes[1].value != '') 
                {
                    Amount = parseFloat(Amount) + parseFloat(gv.rows[i].cells[1].childNodes[1].value);     //getting textbox value
                   
                      tax=parseFloat(tax)+parseFloat(gv.rows[i].cells[2].childNodes[1].value);
                    
                    total=parseFloat(total)+parseFloat(gv.rows[i].cells[3].childNodes[1].value);
                }
             
            }
            document.getElementById('<%=Label1.ClientID %>').textContent = Amount.toFixed(2);
           
              document.getElementById('<%=Label2.ClientID %>').textContent = tax.toFixed(2);
          
            
             document.getElementById('<%=Label3.ClientID %>').textContent = total.toFixed(2);
               
       }
      function Calculatesum()
      {
        var gv = document.getElementById('<%=GridView1.ClientID %>');
            var Amount = 0;
            var tax=0;
            var total=0;
            for (var i = 1; i < gv.rows.length - 1; i++){
                if (gv.rows[i].cells[1].childNodes[1].value != '') 
                {
                    Amount = parseFloat(Amount) + parseFloat(gv.rows[i].cells[1].childNodes[1].value);     //getting textbox value
                   
                      tax=parseFloat(tax)+parseFloat(gv.rows[i].cells[2].childNodes[1].value);
                    
                    total=parseFloat(total)+parseFloat(gv.rows[i].cells[3].childNodes[1].value);
                }
             
            }
            document.getElementById('<%=Label1.ClientID %>').textContent = Amount.toFixed(2);
           
              document.getElementById('<%=Label2.ClientID %>').textContent = tax.toFixed(2);
          
            
             document.getElementById('<%=Label3.ClientID %>').textContent = total.toFixed(2);
           
      }

    </script>


===================================================================>


       <asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
        <Columns>
          <asp:TemplateField HeaderText="Product Name">
         <ItemTemplate>
             <asp:Label ID="Label4" runat="server" Text='<%#Eval("productname") %>'></asp:Label>
         </ItemTemplate>
        </asp:TemplateField>    
       
        <asp:TemplateField HeaderText="Amount">
         <ItemTemplate>
             <asp:TextBox ID="TextBox1" onblur="multiplication(this);return false" runat="server"></asp:TextBox>
         </ItemTemplate>
        </asp:TemplateField>      
         <asp:TemplateField HeaderText="Tax">
         <ItemTemplate>
             <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
         </ItemTemplate>
        </asp:TemplateField>      
         <asp:TemplateField HeaderText="Total">
         <ItemTemplate>
             <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
         </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>

Thursday, 27 December 2012


Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005

One question I’ve seen asked a few times by people over the last few weeks is “how do I setup the new ASP.NET Membership, Role Management, and Personalization services to use a regular SQL Server instead of SQL Express?” This blog entry walks you though a few simple steps on how to-do this.

Quick Review: What are the new ASP.NET 2.0 Application Services?

ASP.NET 2.0 includes a number of built-in “building block” application services.  We call them “building blocks” because they are useful core frameworks for enabling super-common scenarios with web applications today – and as a result can provide significant productivity wins and time-savings for developers.

They include: a membership API for managing usernames/passwords and secure credential management, a roles API that supports mapping users into logical groups, a profileAPI for storing arbitrary properties about both authenticated and anonymous users visiting a web site (for example: their zipcode, gender, theme preference, etc), a personalizationAPI for storing control customization preferences (this is most often used with the WebPart features in ASP.NET 2.0), a health monitoring API that can track and collect information about the running state and any errors that occur within a web application, and a site navigation API for defining hierarchy within an application and constructing navigation UI (menus, treeviews, bread-crumbs) that can be context specific based on where the current incoming user is in the site.

The ASP.NET Application Service APIs are designed to be pluggable and implementation agnostic, which means that the APIs do not hardcode the details of where data is stored with them.  Instead, the APIs call into “providers”, which are classes that implement a specific “provider contract” – which is defined as an abstract class with a defined set of methods/properties that the API expects to be implemented.

ASP.NET 2.0 ships with a number of built-in providers including: a SQL Express provider for going against local SQL Express Databases, SQL 2000/2005 providers that work against full-blown SQL Servers, an Active Directory Provider that can go against AD or ADAM implementations, and in the case of site navigation an XML provider that can bind against XML files on the file-system.

The beauty of the model is that if you don’t like the existing providers that ship in the box, or want to integrate these APIs against existing data-stores you are already using, then you can just implement a provider and plug it in.  For example: you might already have an existing database storing usernames/passwords, or an existing LDAP system you need to integrate with.  Just implement the MembershipProvider contract as a class and register it in your application’s web.config file (details below), and all calls to the Membership API in ASP.NET will delegate to your code.

Default SQL Express Providers

Out of the box, most of the ASP.NET 2.0 application services are configured to use the built-in SQL Express provider.  This provider will automatically create and provision a new database for you the first time you use one of these application services, and provides a pretty easy way to get started without a lot of setup hassles (just have SQL Express on the box and you are good to go).  Note that SQL Express databases can also be upgraded to run in the context of full-blown SQL Server instances – so apps built using SQL Express for development can easily be upgraded into a high-volume, clustered, fail-over secure 8P SQL box when your app becomes wildly successful.

How do I change the providers to use SQL Server Instead of SQL Express?

If you want to use a full-blown SQL Server 2000 or SQL Server 2005 database instance instead of SQL Express, you can follow the below steps:

Step 1: Create or obtain a blank SQL database instance

In this step you’ll want to create or obtain a connection string to a standard SQL database instance that is empty.

Step 2: Provision your SQL database with the ASP.NET schemas

Open a command-line window on your system and run the aspnet_regsql.exe utility that is installed with ASP.NET 2.0 in under your C:\WINDOWS\Microsoft.NET\Framework\v2.0.xyz directory. 

Note that this utility can be run in either a GUI based mode or with command-line switches (just add a -? flag to see all switch options).

Using this wizard you can walkthrough creating the schema, tables and sprocs for the built-in SQL providers that come with ASP.NET 2.0.  The below screens show the step-by-step walkthrough of this:











Once you have finished walking through the wizard, all the database schema + sprocs to support the application services will have been installed and configured (note: if your DBA wants to see exactly what is going on behind the covers, we also ship the raw .sql files underneath the above framework directory, and your DBA can walkthrough them and/or run them manually to install the DB).

Step 3: Point your web.config file at the new SQL Database

ASP.NET 2.0 now supports a new section in your web.config file called “<connectionStrings>” which (not too surprisingly) are used to store connection strings.  One nice thing from an administration perspective is that the new ASP.NET Admin MMC Snap-in now provides a GUI based way to configure and manage these:



ASP.NET 2.0 also now supports encrypting any section stored in web.config files -- so you can also now securely store private data like connectionstrings without having to write any encryption code of your own. 

ASP.NET 2.0 ships with a built-in connection string called “LocalSqlServer” which by default is configured to use a SQL Express database, and which by default the Membership, Roles, Personalization, Profile and Health Monitoring services are configured to use.

The easiest way to have your application automatically take advantage of your newly created SQL database is to just replace the connectionstring value of this “LocalSqlServer” setting in your app’s local web.config.

For example, if I created my database on the local machine in an “appservicesdb” database instance and was connecting using Windows Integrated security, I would change my local web.config file to specify this:

<configuration>

    <connectionStrings>
        <remove name=”LocalSqlServer”/>
        <add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=appservicesdb;Integrated Security=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>

</configuration>

Hit save, and all of the built-in application services are now using your newly created and defined SQL Server database.

Note: The one downside with the above approach is that I’m re-using the “LocalSqlServer” connection string name – which will feel weird if/when I deploy my database on another machine.  If I wanted to name it with my own connection string name, I could do this simply by adding a completely new connection-string, and then pointing the existing providers to use the new connection-string name in place of the default LocalSqlServer one. 

Hope this helps,

Thursday, 20 December 2012


Tip - Missing Add Service Reference in Visual Studio 2008(and above)??


If we choose any Framework earlier than .NET Framework 3.0 while creating project or migrate an existing project from older version of Visual Studio, we might not find Add Service Reference in the context menu when you right click on the project. Here is a way to update to the framework version of the project and get Add Service Reference option in the context menu (Project should be saved before doing this) ,

Right click on the project and navigate to the following path,

Compile->AdvancedCompileOptions(button)->TargetFramework(dropdown)

Change the Framework version to .NET Framework 3.0 (or above)

Now we should be able to see Add Service Reference option!!!!!!


(or)

Project-->RightClick--> select Property Page--> Select Built tab -->
TargetFramework(dropdown)

Change the Framework version to .NET Framework 3.0 (or above)