Showing posts with label Errors and Solution. Show all posts
Showing posts with label Errors and Solution. Show all posts

Friday, February 19, 2016

The underlying provider failed to open error in C#

 

This is one of the very common error we use to get while using Oracle database. The error “The underlying provider failed to open” is bit confusing if you are not able to view the inner exception.

Once you get the exception, just expand the exception try to read the inner exception. Whihc will be more clear than this.

I just exapanded the exception and the actual error we get is “ORA – 12154: TNS:could not resolve the conect identifier… ” If you read this exception it will be more clear and you might know what needs to be done.

Below is the screen print of the error.

image

I assume you have installed Oracle client in your machine. This error just because you missed the 3 required files

1. tnsnames.ora

2. sqlnet.ora

3. ldap.ora

So in order to resolve the error “ORA – 12154: TNS:could not resolve the conect identifier…” you have to copy three files to the oracle installation location.

Oracle installation folder may vary depends on where you have installed the software and the windows version.

I have given you two possible location normally oracle get installed.

C:\app\client\<Userid>\product\12.1.0\client_1\network\admin

or

C:\Oracle\product\12.1.0\client_1\Network\Admin

If you cannot find Network and Admin folder in Client_1 path you may create those two folders.

Now you try to run the code and see if the issue gets resolved or not.

I hope it helps you to resolve the issue.

Thanks you for visintg my blog.

Sunday, January 10, 2016

Build failed without any error in Visual Studio 2013 update 4

This is one of the very strange error you may find sometimes. Especially when you build a new system or when you install visual studio 2013 first time.

There are many reasons for this error. If you search in Google you may find many solutions here I am going to give you a different solution which worked for me after a thorough investigation.

What happened in my case was, when I open Visual Studio 2013 it shows as running in Administrator mode, but actually it is not. I didn’t right click and run as administrator while opening Visual Studio.

image_thumb2

Now if you build your application which require administrator rights your build may fail. Again not always and not all projects.

So to resolve this issue what you have to do is open Visual Studio in Administrator mode. Just right click on the Visual Studio 2013 from the start menu and click on Run as Administrator. Now you try to build the project which failed without any error. It must work.

image_thumb4

I hope it helps, as I mentioned at the top this is not the only solution to this problem, but this is definitely one of the solution which worked for me. So thought of sharing with you all.

Wednesday, March 11, 2015

Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format. - WCF IIS Hosting error

“Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format” is an error which you get while hosting the WCF service in IIS.

Lets see the complete exception details first,

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.

image

Reason for this error:

You get this error normally when you try to host a WCF service developed in Windows 32 bit machine and you are trying to host this in a 64 bit machine.

Solution to this issue is a simple one, you just need to change the settings in IIS to enable 32 bit application hosting.

Lets see the step step by actions to change this settings.

Open IIS --> Press Start button + R and then type inetmgr.

Expand your server and then click on Application Pools

In the list of application pools select the application pool which is being used by your new WCF service. And then click on the “Advance Settings…”

image

In Advance Settings dialog change the Enable 32-Bit Applications settings from False to True and Click OK.

image

Now you browse your WCF service and see the result. I am sure your error would have disappeared.

Friday, March 6, 2015

The requested content appears to be script and will not be served by the static file handler – WCF IIS Hosting error

This is one of the most confusing error you get while hosting WCF service in IIS. Solution is simple but the error description completely misleads you to think in all the direction.
Below is the exact error,

HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.

image

The reason for the error is when you host a WCF service which is developed in .NET Framework 4.0 or 4.5 then while deploying by default IIS select .NET Framework 2.0.

In order to resolve this issue go to IIS and change the .NET Framework to the version which was used to develop your WCF service.
The exact step would be,

Press Start button  + R  and then type inetmgr.

Expand your server and then click on Application Pools

In the list of application pools select the application pool which is being used by your new WCF service.

Here you would have already noticed the wrong framework associated with your WCF service.

Just double click on the WCF Service name and change the .NET Framework version.

image
Click OK to save the changes. Now you browse your WCF service all your issues with your WCF service hosting error would have resolved.

Thursday, February 26, 2015

How to Enable Failed-Request Tracing / Not able to find Failed-Request Tracing option in IIS

Sometimes we have to enable Failed request tracing in order to trace the issues in the server. Normally we use Failed Request tracing to know what exactly is happening with the request. Best examples to enable Failed Request tracing is to find out the performance issues, authentication failures, Server 500 error, 404 error etc.

Sometimes when you try to configure the Failed Request Tracing you may not find that option because you may not have installed the IIS components to enable that feature. So first lets see the place where you will find this option.

Lets open IIS first, press Window + R button or Start –>Run and then type inetmgr.
Expand your system name—>Sites—> Click on Default Web Site.

Now look at your right side window “Actions” In Actions pane under Configure section you should get “Failed Request Tracing…. “ option.

Sometimes as I mentioned above you may not see this option. It will be like below screen.

 image
In such cases first we will install the required component.

Go to Control Panel\All Control Panel Items\Programs and Features and then click on Turn Windows features on or off.

Go to Internet Information Service-->World Wide Web Services--> Application Development Features—> Select ASP.NET

Expand Health and Diagnostics—>Select Tracing

Click OK to install this component.

image

Once you install above components open IIS again and go to the Action and under Configure section you can see Failed Request Tracing…

image
To enable Failed Request Tracing Click on the link “Failed Request Tracing…. “ and select the Enable button. You can also change the path in case you wanted to save this log file in a different location than the default location. Also as you can see you will be able to change the Maximum number of trace files as well. This is to avoid your Disk getting full with trace files. Last 50 or 100 file would be sufficient to investigate any issues.
image
I hope now you are clear on how to enable Failed Request tracing and were you can see the Trace log files.

Wednesday, February 18, 2015

App Suspended feature in .NET Framework 4.5.1

Today we will go through one of the new feature added in .NET framework 4.5.1. This feature is currently available only in Windows Server 2012 R2. Microsoft may add this in other operating systems later but currently this is restricted to Windows Server 2012 R2.

App Suspend is a new configuration in IIS in Windows Server 2012 R2. We will see what is the advantage we are going to get if use this configuration and also will see where we have to change this configuration.

First thing first! What is the advantage of using app suspend?

If you enable this great feature your application start up will be much faster and in single webserver server you can host multiple application without impacting the performance.
image
Now, lets see how enable this feature.

In order to enable first we will open IIS from your Windows Server 2012 R2. Open IIS—> Select Application Pools—> Right Click on Application Pools and then select the “Advance Settings…”.

In advanced Settings window you will not see this feature anywhere! isn’t it? Yes you cannot see this feature directly. This feature is part of the “Idle Time-out” settings.
 
You would have noticed a special configuration here that is nothing but the “Idle Time-Out Action” this is currently available only Windows Server 2012 R2. This is the configuration we have to change. By default it will be selected as “Terminate”.
 
Just click on this dropdown to see that the new option “Suspend”. and select the same and click on OK to return.
image
That’s all you have to do, you are done!!!

If you like to test this feature then change the default time to 2 min or something and access the application. Also change the setting back to terminate and see your application start up time difference.
I hope you understood the advantage of this App Suspend feature and you will try this in your application.

Thursday, February 12, 2015

Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Recently when I was debugging my application I got the error “Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Below is the exact error I have received.

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.

image
I was very mush sure that I have proper permission in my system and also I am running Visual Studio in Administrator mode. So there is no way I should get security exception.

First thing I checked was the TRUST level in web.config but found that it was set to FullTrust. They suddenly I realized that I am running the code from remote share, I mean from the network drive.Therefore, the remote share that holds the Web applications content requires FullTrust.

There are two ways to solve this error,

1. Copy the complete code in your local drive and run, since you are an administrator to your system there won’t be any issues.

2. Provide FullTrust to your network drive. To provide FullTrust to your network drive you have to follow certain steps. This steps are already documented in Microsoft KB article. I would like you to go through this steps in case if you are interested to provide FullTrust to your network drive.

I hope you are able to resolve this issue now and you are able to debug your application without any problem.

Thanks for reading my article. Please rate the article by clicking on the buttons below.

Tuesday, January 6, 2015

Error 8672 in MS SQL 2008 while using Merge statement

This is one of the weird error you get in MS SQL 2008 if you have Merge statement in your query.

Below is the complete exception message which you may receive. 

The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows. [SQLSTATE 42000] (Error 8672).

Interesting thing about the above exception is you will get this exception even if you don’t have duplicate rows are there during the join operation. When I got this message I was checking for the duplicate rows first as the error message was highlighting that.

Any way Microsoft informed that this is a bug in SQL Server 2008. In order to resolve this issue you have to install Cumulative Update 6 for SQL Server 2008 Service Pack 1. You can download the same from Microsoft Download centre. Here is the link for “Cumulative Update 6 for SQL Server 2008 Service Pack 1”.

Microsoft created a KB article to address this issue. If you are interested to know more about this issue please refer Microsoft KB article.

I hope after installing the above updates your error is disappeared and the same query is running without any issues.

Thursday, December 11, 2014

Not able to see Attach Debugger in Visual Studio for remote debugging in Azure

This is one of the common issue developer faces when they try to debug the azure webiste. In order to debug the Azure website from your local machine you should attach the debugger to your website. This “Attach Debugger” option will be visible in your server explorer. Lets us see how you can reach there first.
In order to debug the Azure website remotely first you have to open Server Explorer from the View menu. Once you click on the Server Explorer just expand the Windows Azure section. If you are not logged in to Azure account It may prompt you to login. Once you connect to your Windows Azure account you will be able to see all your websites which is already hosted in your Azure account.

Tuesday, November 18, 2014

Attempt by security transparent method 'System.Web.Http.GlobalConfiguration.get_Configuration()' to access security critical type 'System.Web.Http.HttpConfiguration' failed.

This is one of the common error you may experience while using WEB API. This error normally occurs if you are using older version web API.
So the simple solution to resolve this issue is upgrade your WEB API.
Easiest option to upgrade your WEB API is by using NuGet package manager.

Monday, November 10, 2014

Filtered Index in MS SQL

What is filtered index? What is the benefit of using filtered index? Does filtered index really improves the performance? All these queries will be answered in this article.
Lets start with what is filtered index? A kind of interview question.
Filtered index is an optimized non clustered index. Filtered index is more suitable for the queries which select the data from a well defined subset. Important thing you have to remember about the filtered index is it uses the filter predicate to index only a portion of rows in a table. This is what I have mentioned above that “filtered index is suitable for the queries which select the data from a well defined subset”.
Does the filtered index improve the performance?

Sunday, June 1, 2014

How to re-create designer.cs in Visual Studio 2013

Some time you may have to re-create .designer.cs file of your .aspx page. There can be many reason for re-generating this file. You must be surprised to know that there is no direct option to re-generate .designer.cs file. All you have to do is workaround, but it generates the file without any error and application doesn’t throw any error.
Let’s see the step by step process by deleting the designer .cs first.
image

Tuesday, May 20, 2014

Not able to access classes in the App_Code folder in Visual Studio 2013

You might be wondering why my classes inside the App_Code folder is not accessible when you are trying to add reference in the code behind page. This is one of the common issue and the solution is very simple. Here in this article I will be helping you to resolve this issue.
To resolve this issue what you have to do is right click on the class file and then select the properties.
image

Tuesday, January 21, 2014

Could not load file or assembly 'AjaxMin, Version=4.97.4951.28478, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.

This is one of the common error you get when you start using AJAX first time in your project. Nothing to panic about this, you can easily resolve the error “System.IO.FileNotFoundException: Could not load file or assembly 'AjaxMin, Version=4.97.4951.28478, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.” by copying the missing dll in the correct folder.

image

If you look at the error once again you may notice that error clearly suggest it cannot find the assembly 'AjaxMin’ which means once you open your project bin folder you may not find the 'AjaxMin.dll’ file.

So to resolve this issue what you have to do is, search for 'AjaxMin.dll’ and copy this into the project bin folder.

image

After copying this 'AjaxMin.dll’ in your project bin folder try to run the application and see if it works fine.

Saturday, September 21, 2013

0x800a138f - JavaScript runtime error: Unable to get property 'UI' of undefined or null reference

You might be wondering what is this error and what you have to do to resolve “0x800a138f - JavaScript runtime error: Unable to get property 'UI' of undefined or null reference” error. Here is the answer for you.

Reason for this error: This error normally occurs when you use ScriptManager, like below, because most of the controls from AjaxControlToolKit work using Ajax script unfortunately many Ajax scripts are not updated in ScriptManager.

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager> 

image

Solution to resolve this error: You have to use ToolkitScriptManager instead of ScriptManager. ToolkitScriptManager adds most of the updated Ajax Script. Your code after changing must be like below,

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
 </asp:ToolkitScriptManager>

After changing to ToolkitScriptManager run your project and see the output.

Monday, September 2, 2013

The Report Server Installation Is Not Initialized (rsReportServer Not Activated)

This is one of the common error you may get when you rebuild or restore or upgrade your reporting server database and browse the report service manager URL. You may get the similar error when you browse the .rdl report also which was working earlier when your server was running fine.

To resolve this error you may follow one of the below steps,

Option 1:

  • Open Reporting Services Configuration Manager
  • Go to Encryption Keys
  • Delete Encrypted Content
  • Click on Delete

Option 2:

  • Go to Reporting Services Configuration Manager.
  • Go to "Encryption Keys" to backup the key.
  • Navigate to "Database" tab.
  • Click "Change Credentials" to reset the connections.

Now you will be able to browse the report without any issue.

Monday, August 5, 2013

How to enable Script debugging in web browser?

In this article I am going to explain you how to debug JavaScript or how to enable Script Debugging.

I have seen many people posting question in forum asking I am getting “Java script rut time error” and how to resolve this issue. Interestingly they post whole JavaScript also for the solution. With my experience it is bit hard to find out the actual issue in JavaScript if you are not able to find the exact line you are getting this exception.

Many people still not aware that we can debug JavaScript and find out the exact line where we are getting the script error.

To find the exact line where the exception is showing first we will enable the Script debugging in web browser. In this example I am using Internet Explorer.

To enable the JavaScript debugging in Internet Explorer follow below steps.
Open IE-->Go to Tools-->Internet Options—>Select Advanced Tab—>

Scroll down to Browsing section-->Un Check "Disable Script debugging (Internet Explorer)" and Uncheck "Disable script debugging (Other)" and Check "Display a notification about every script error".

Script Debugging

Click Ok to save the changes.

Now close your browser and open your web page and see the error message as pop up.

Script Debugging1

Click yes to open the script debugging and see in which line you are getting this error. Exact line you are getting this exception will be highlighted.

Script Debugging2

Now it will be very easy for you locate the line your script from your .aspx page.

Sunday, July 21, 2013

Server Error in '/' Application, Maximum request length exceeded

Below is one of the common error developers get when they try to upload huge files using ASP.NET application.

Error description:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Maximum request length exceeded.
Description: An unhanded exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.

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.

Reason:

users are trying to upload huge files which is more than the default size allowed by .NET Framework.

Solution:

Change below settings in web.config depends on the IIS version you are using.

For IIS6

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

For IIS7

<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

You may change the values depends on the file size you want to allow the users to upload.

Try to run your application and upload some files!!!

Tuesday, April 30, 2013

Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: Incorrect syntax near ''

I have received this ‘Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: Incorrect syntax near '<some Keyword>' error when I migrated my application from SQL server 2005 to SQL server 2008.

What happened is after migration, database compatibility was still set to previous version. So when we ran any SQL script which doesn’t support previous version will throw error.

To resolve this, you just need to login to the SQL server and change the compatibility level.

If you are getting this error while migrating the database from SQL 2000 to SQL 2005 then you may select the option “SQL Server 2005 (90)”

If you are getting this error while migrating the database from SQL 2005 to SQL 2008 then you may select the option “SQL Server 2008 (100)”

If you are a database admin then you can directly open the SQL query analyzer and execute below SQL query,

EXEC sp_dbcmptlevel 'DatabaseName', 90 ---This is for SQL 2005 Migration
EXEC sp_dbcmptlevel 'DatabaseName', 100 --–This is for SQL 2008 Migration

Steps to follow if you are doing it directly on server,

  • Login to the database server.
  • Locate the database you are getting this error
  • Right click on the database and select Properties
  • Go to “Options” Page
  • Here you will find the option to change the “Compatibility Level”

Below screen print will give you the clear idea of all the options and what you need to change.

Change Compatibility Level

You are always welcome to post your comments below.

Monday, August 20, 2012

Debugging is not supported under current trust level settings?

Today When I was debugging a test website I created for learning I got the error “Debugging is not supported under current trust level settings?

This error normally occurs when you keep the website directly under C:\inetpub\wwwroot folder. Anyway that is not a subject here. We will directly go to the simple solution to resolve the issue.

Open your Web.config and add below line in

<system.web>
    <trust level="Full"/> 
    .....
    .....
</system.web>