Showing posts with label ASP.Net Debugging Problems. Show all posts
Showing posts with label ASP.Net Debugging Problems. Show all posts

Tuesday, November 5, 2013

Current Transaction Cannot be Committed

Error:
The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction.

This error occurs when you try to perform other operations when any transaction fails in try catch section, soon after it goes to catch section.

Solution:
You have to ROLLBACK first on the catch section before doing any other operations.
Share:

Tuesday, May 10, 2011

Object Name is Not Declared

Error BC30451: Object_name is not declared
An object, e.g. button, linkbutton, or lable is created on the .aspx page. The intellisense does detect the object name. However, when it is debugged, it gives the error Object_name is not declared, where Object_name is the name of the object.

Solution:
1. If you are web application project, try deleting the aspx.cs or aspx.vb (code) file, then right-click the .aspx file, and choose Convert to web application.

2. Check if there is another copy of the same files in the same folder. This happens to me quite some times. Before doing major changes, I usually make a copy of the files first. The files are usually automatically included in the solution we are developing. Since the class of the copies have the same names, they conflict each other. Move the copy from the folder or simply exclude the copies from the solution by right-clicking on the files, then choose "Exclude From Project". See if it solves the issue.

3. If neither solution 1 nor 2 solves the issue, try adding new files with different names, then copy the content of the old files to the new ones. Note that the names of the class can not be the same. Try compiling and see if it works. If it does, you can then delete or move the old files, then rename the new files according to the old ones.

4. If none of the alternatives above work, try finding from internet, then POST IT HERE! Thanks ^_^
Share:

Friday, March 18, 2011

Object tag not recognized inside form tag

Problem: When developing a page in ASP.NET, an object tag (<object>) is not recognized when it is placed in an HTML form tag (<form>).

e.g.
<html>
<head>
   <script type="text/javascript" language="javascript">
    function readScript()
    {
        Card.Connect();
    }
   </script>
</head>


 <body color=white>
    <form name="frmRead" id="frmRead">
        <object id="Card" name="Card" classid="abcDll.dll#abcDll.Card" style="display:none" ></object>
        <input type=button value="Read Card" onClick="readScript();"></td>
    </form>
 </body>
</html>

Solution: Inside the <form> tag, <object> element is out of scope. Instead of directly calling the id of the object, get the id using javascript.
function readScript()
    {
        var cardObj = document.getElementById("Card");
        cardObj.Connect();
    }

Special thanks to StackOverFlow :D
Share:

Wednesday, March 16, 2011

Cannot Run Web Application

Problem: ASP.NET web application can not be run.
Error: WebDev.WebServer.exe has encountered a user-defined breakpoint.


Solution:
The web application you are developing is using Visual Studio development server with dynamic ports. At the same time, you have the same or another web created and running under the same port in IIS.
1. Either stop the IIS for the web which is using the same port as the web application you are going to run under visual studio development server.
2. Or, change the port number of the web application running under visual studio development server. To do this, click on the website, then change the port number in the Properties Window.

Share:

Running ActiveXObject from Javascript

Problem: Can't run ActiveXObject from Javascript
Error: System.Security.Permissions.SecurityPermission

This error occurs when you are trying to run ActiveXObject / dll using Javascript.


Solution:
A. Setting the security for the internet browser, i.e. Internet Explorer
1. Using Internet Explorer, set the security to low: Goto menu Tools -> Internet Options.
2. Goto tab Security.
* Under Internet zone, set security level to Low. Click Custom level button, in ActiveX controls and plug-ins section, Enable Script ActiveX controls marked safe for scripting*, then click OK.



* Under Local intranet zone, click Custom level button, enable things under ActiveX controls and plug-ins section, and the most important one, Enable Script ActiveX controls marked safe for scripting*, then click OK.



B. Setting .Net Framework 2 Configuration
1. Make sure you have .Net Framework 2 SDK installed on your computer. You may want to install it if you have not had it installed on your computer.
2. Goto control panel -> Administrative Tools -> open Microsoft .NET Framework 2.0 Configuration.
3. On the Tasks, click Configure Code Access Security Policy -> Adjust Zone Security -> Make changes to this computer, and Next. Set My computer & Local Intranet to Full trust, then Next -> Finish.




Restart the Internet Explorer, then try running the Web page again.

PS: While it is not recommended to run untrusted ActiveX Object, because it may cause security leak; this is a workaround to solve the problem in case it is necessary to run the ActiveX Object on client side.
Share:

Sunday, December 5, 2010

Login failed for user 'XXX\ASPNET'

Error:

Server Error in '/ExamWebsite' Application.

Login failed for user 'XXX\ASPNET'.

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.Data.SqlClient.SqlException: Login failed for user 'XXX\ASPNET'. Source Error:
Line 60:                 DataTable dt = new DataTable();
Line 61: 
Line 62:                 conn.Open();
Line 63:                 cmd.Connection = conn;
Line 64:                 cmd.CommandText = "spr_GetVisit";
Note: XXX = the name of the user.

This error usually occurs when using integrated security for the database connection.

Solution:
For SQL Server 2000's users:
1. Go to SQL Server Enterprise Manager.
2. Expand the tab Microsoft SQL Servers -> SQL Server Group -> Server used -> Security.
3. Right Click on Logins, then select New Login.
4. On the Name textbox, type xxx\ASPNET, then click "..." on the right. (where xxx is the name of the user). Choose ASPNET on the new dialog window displayed, then click Add -> OK.
5. On Server Roles tab, check System Administrators.
6. On Database Access tab, check the databases to be used, and check the roles as public and db_owner.
7. Click OK.
Share:

Wednesday, September 30, 2009

Fail creating virtual directory

Error: Creation of the virtual directory http://localhost/web failed with error: Could not find the server 'http://localhost' on the local machine. Creating a virtual directory is only supported on the local IIS server.

This error appear as a dialog box when trying to load a project whose virtual directory had been created formerly.

Actually, there are two dialog box:
1. The first dialog box sounds: The local IIS URL http://localhost for Web project web has not been configured. In order to open this project the directory needs to be configured. Would you like to create the virtual directory now?

2. After clicking yes, the second dialog box appears: Creation of the virtual directory http://localhost/web failed with error: Could not find the server 'http://localhost' on the local machine. Creating a virtual directory is only supported on the local IIS server.


Solution:
The solutions may vary in this case. Here are some possible solutions:
1. Make sure the asp.net is already registered to the IIS. You may want to try registering it to IIS

2. The virtual directory of the project might not have been set properly, so it can not be loaded. Edit the virtual directory of the project by right-clicking the project, choose Edit project (.csproj) file, then at the bottom part of the file, you may find something like <iisurl>http://localhost/</iisurl>
Change / add the name of the web project, e.g. <iisurl>http://localhost/webname</iisurl>

3. Make sure the IIS is running well on services.msc. To check it, press windows + Run, type "Services.msc" (without quotes), then restart IIS Admin.



Afterwards, restart the IIS by pressing windows + Run, type "inetmgr" (without quotes), then start the service.



4. This is a rare case, but someones might encounter it too. If you are using another web server on your computer, e.g. Apache, xampp, etc., make sure you stop the web server first, then start the IIS. In a case I met, it still didn't work, after about half an hour trying to find the problem, I found the issue. Someone changed the port used for the web server. So, I had to change it again.
On the IIS window, right click on the Default Web Site, choose Properties, then make sure the port used is 80 (I'm not sure if using another port is ok here).

Share:

Tuesday, July 28, 2009

Unable to start debugging on the web server

Error : Error while trying to run project: Unable to start debugging on the web server. Server side-error occurred on sending debug HTTP request.

Make sure the server is operating correctly. Verify there are no syntax errors in web.config by doing a Debug.Start without Debugging. You may also want to refer to refer to the ASP.NET and ATL Server debugging topic in the online documentation.

This error appears as a dialog box while trying to debug a web application.

Solution : Run the application without debugging. You can :
1. Use Ctrl + F5, not F5, or
2. Directly type the URL address on the browser, or
3. Open IIS by pressing window + R, then type inetmgr, expand the web application under development, and browse it

You'll see the source of the error.

In a case I met, it's because of the unavailability of an impersonate user on the computer, while in the web.config, an impersonate user is used.

In case you meet the same condition; and in the web.config, there exists such code as:

<identity impersonate="true" username="uploaduser" password="uploaduser">



Go to Computer Management by pressing Window + R, then type "compmgmt.msc" (without quotes) -> Expand Local Users and Groups -> Users. If the user : uploaduser defined in web.config does not exist there, make the user by right-clicking, New User -> fill the user's information. Otherwise, if the user already exists, make sure that the account is not disabled. Just enable it by going to the properties if it is currently disabled.
Share:

Thursday, July 23, 2009

CustomError mode

Error :

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>

Solution : The exact error hidden in this error message may vary. To reveal and see the error, changing the customErrors mode is necessary.
In web.config, change to mode to RemoteOnly or Off.
Changing the mode to RemoteOnly will enable the error message to be displayed when the web is viewed on the server.
Meanwhile, changing the mode to Off will enable the error message to be displayed when the web is viewed either on the server of outside.


<customErrors mode="Off" defaultRedirect="ErrorPage.aspx">
<error statusCode="404" redirect="ErrorPage.aspx?errNo=404"/>
</customErrors>
Share:

Adding web reference in Visual Studio 2008 or later

Some people get confused adding web reference in Visual Studio 2008 or later, since it's not by default in the Solution explorer. Only Service reference is shown.

Web reference is actually still available on Visual Studio 2008 or later.
Just right-click on the project where the web reference is to be added, choose Add Service Reference, then click Advanced button. Click Add Web Reference beneath, then insert the URL address of the web service, Go. If the URL address is correct, it will be shown in the listbox saying "Web services found at this URL". Insert the reference name, then click Add Reference, OK.

That's all folks ^^
Share:

Thursday, June 25, 2009

Fail loading Web Application Project

Error : I do not quite remember the exact error, encounter it long time ago, and just now, a friend asked about it again. The error contain the words ..... System.Runtime.InteropServices.COMException...

It is characterized by web application project not being loaded while opening a solution, while any other projects open well.

Solution : Check whether IIS is installed on the computer. Press window + Run, type "inetmgr" (without quotes). If IIS is installed on the computer, Internet Information Services window should appear. Otherwise, you should install IIS first, then try opening the solution again.

To install IIS, go to Start Menu -> Control Panel -> Add or remove programs -> Add or remove windows components -> Check Internet Information Services, then click details -> don't forget to check FrontPage 2000 Server Extensions (if not checked yet) -> Click Next. It will asks to insert windows installer CD.
Yes, the IIS is on the windows installer CD, so you have to own a windows installer CD.
Share:

Debug not working on VS 2003.Net

Problem : Debug is not working on Visual Studio.NET 2003. There are some problems with Visual Studio 2003. Yet, still using it in some projects. One common problem is that the debug is not attached to the process while run in debugging mode. Hence, the breakpoints set will not be hit. This is sometimes annoying, when errors occur, and we're looking for the source of error.

Solution : Just run the application as usual, using F5, then on VS, choose menu Debug -> Processes -> look for aspnet_wp.exe. If more than 1 version are used on the computer, there might be more than 1 aspnet_wp.exe listed on the processes.

Choose any (if more than one available) aspnet_wp.exe process, then click Attach. A dialog box will appear. The process detail will be prompted, e.g.
It should look more or less like this :
[3644] c:\windows\microsoft.net\framework\v1.1.4322\aspnet_wp.exe

Notice that if the text in blue is not in v1...., then you should have chosen the wrong aspnet_wp.exe process. Cancel, and choose another aspnet_wp.exe process.

If there are more than 2 versions of VS used in the computer, i.e. 2003, 2005, 2008, etc., there should be :
[3708] C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_wp.exe -> .net Framework 2, for VS 2005 and above

[3644] c:\windows\microsoft.net\framework\v1.1.4322\aspnet_wp.exe -> .Net Framework 1, for VS 2003 and prior

Then, check only the Check box which says : Common Language Runtime, then OK.
Share:

Thursday, June 18, 2009

Can not add service reference / web reference

Error : The components required to enumerate web references are not installed on this computer. Please re-install Visual studio.

This error pops up as a dialog box while trying to add service reference / web reference.

Solution : Press window + Run, then type "devenv /resetskippkgs"
(without quotes), then press Enter.

This command clears all options to skip loadings added to VS Packages.

Then, try adding the service reference / web reference again.

Share:

Error with web service

Error variations:
- No connection could be made because the target machine actively refused it.
- The request failed with HTTP status 404: Not Found

Solution : Check whether the URL for the web service is set properly.

This problem appears to be a debugging problem when web service is used for desktop application. Yet, it appears to be a deploying problem when the web service is used for web application.
Share:

Monday, May 18, 2009

Redirecting and hiding URL

Problem : I wanted to make a link that will redirect the users to download a pdf file. Yet, I have to hide the URL, and can't let the users know the URL to the file.

Solution : I use repeater to hide the URL by using CommandArgument and CommandName attributes.

I make a repeater which looks more or less like this on the aspx:


<asp:repeater id="rpt" runat="server" onitemcommand="rpt_ItemCommand" onitemdatabound="rpt_ItemDataBound">
<itemtemplate>
<asp:linkbutton id="linkFileName" runat="server" cssclass="link3"></asp:linkbutton>
</itemtemplate>
</asp:repeater>



Then on the CS:

protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
ClassData classData = (classData)e.Item.DataItem;
LinkButton linkFileName = (LinkButton)e.Item.FindControl("linkFileName");
string fileName = classData.FileName;
linkFileName.Text = fileName;
linkFileName.CommandArgument = classData.FileName;
}
}


protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + e.CommandArgument);
Response.Flush();
Response.WriteFile("D:\folder\" + e.CommandArgument);
Response.End();
}
}
Share:

Cannot create/shadow copy when file already exists

Error : Cannot create/shadow copy '..........' when that file already exists.

Solution : Rebuild solution / Clean solution, then rebuild.

Don't know why this actually happens. But it happens often, after building solution without debugging for times.
Share:

Tuesday, May 12, 2009

Using System.Web.Routing

Use URL Routing on application recently, and find some difficulties when developing.
When opening page which applies URL routing, it shows error that the page doesn't exist.

Should check this point:
Add a wildcard mapping .* to aspnet_isapi.dll and make sure that Check that file exists is unchecked.

Go to IIS, right click the virtual directory of the application, then choose Properties -> Configuration -> Add -> Browse Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (this path may differ), then find aspnet_isapi.dll, then set the Extension: .*, don't forget to uncheck Check that file exists -> OK.
Share:

Wednesday, May 6, 2009

Browser asks for username & password while debugging

Problem : The browser keeps asking for username and password while debugging.

Solution :
1. Check on IIS if you're using IIS, by pressing window + R, then type "inetmgr" without quotes. Go to the website on the default web site. Then right click, properties, on directory security, check Anonymous Access, and make sure you also check Integrated Windows Authentication.

2. Make sure the application being developed is not located on shared folders such as My Documents, Desktop, etc. If it is indeed on one of those folders, move it to another folder on the local drive, e.g. C:\, D:\, etc.
Share:

Friday, April 24, 2009

Can't debug on IE

Error : I forget about the error messages. If I'm not mistaken, the error message was just as common. As far as I remember, it sounds like this :

Unable to Start Debugging on the Web Server... user is not a member of "debugger users"


Solution : Run Internet Explorer (it should be more or less the same in other browsers), choose menu Tools -> Internet Options -> Security tab -> Choose Local Internet -> click Sites button -> click Advanced -> add http://localhost to the zone, then ok.
Share:

ASP.NET State Service

Error :
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the
value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Param
eters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.


This is also one of the mostly retrieved errors. This error occurs when using StateServer mode for the sessionState in web.config, yet the ASP.NET State Service is not started.
I met this error when I first made a web application. After I get the solution, I ask a little about about StateServer sessionState mode to a senior.

When making an application with login page, u can consider using StateServer for the sessionState mode, because when u use this mode, u don't have to login again and again, just have to refresh the web page, because the session is still kept on server. Yet, when deploying the application, should omit it, or change it to InProc mode. I used only these 2 modes. Never use the SQLServer mode.

e.g.
<sessionState mode="StateServer" stateconnectionstring="tcpip=127.0.0.1:42424" sqlconnectionstring="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="200000" />



Solution:
Start the ASP.NET State Service on Services. Go to control panel -> Administrative Tools -> Services, or simply press window + Run, then type services.msc. Choose ASP.NET State Service, right-click, then Start the service. To start it automatically, choose startup type : Automatic.
Share:

You may be intersted in

Related Posts

Updating Table Containing Xml Column via LinkedServer

If you are trying to update a table containing XML column via Linked Server in SQL Server, and you are not able to, you are not alone. There...

About Me

My photo
Is an ordinary man, with a little knowledge to share and high dreams to achieve. I'd be glad if I can help others, 'coz the only thing for the triumph of evil is for a good man to do nothing.

About Blog

You can find a lot of debugging and deploying problems while developing applications in .NET and Visual Basic here. There are also some querying tips in SQL and typical source codes which might be useful shared here.

Popular Posts

Blogroll

Followers

Leave a Message