Panel pnl_Confirmation = (Panel)form1.FindControl("ConfirmationPanel") as Panel;
pnl_Confirmation.Visible = false;
I keep getting a "NullReferenceException" in the above code. "ConfirmationPanel" is a panel I show/hide depending on if the form is submitted successfully or not.
The panel is wrapped in a LoginView control, which is why I cannot call "ConfirmationPanel" directly:
I'm working on having two forms that communicate together. In order to do this, I am passing public value from the source page. Here's how I did it:
In the source page I have:
Public ReadOnly Property CurrentCity() As String Get Return txtboxfake.Text End Get End Property Then under page_load of the page I have: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtteam.Text = PreviousPage.CurrentCity txtboxdate.Text = Calendar1.SelectedDate End Sub
For some reason I keep getting an error that says "NullReference exception unhandled by user code" that points to txtteam.text = PreviousPage.CurrentCity.
Im having issues with a webform that previously worked before I added a dropdownlist.selectedindexchanged event related to the data that the details view displayed. I ran it in debugging mode and the variable has a valid value. Heres the line Im getting the error on:
Hello all. I created a class that runs fine when using it with web forms, however when i create a Windows service and try to run it I recieve a NullReference error. Im not sure what else to do since the class works fine.Here is a snippet.
The service
public partial class Service1 : ServiceBase { //Timer object Timer RunTime; QBridge bridge_object = new QBridge() double test_interval = 40000; //test value public Service1() { InitializeComponent(); } protected override void OnStart(string[] args) { //Send email notification that intakes were pushed //bridge_object.SendNotification(bridge_object.service_startedtext); RunTime = new Timer(30000); //set the elapsed event RunTime.Elapsed += new ElapsedEventHandler(RunTime_Elapsed); //RunTime.Interval = SetInterval(); //calculated interval RunTime.Interval = test_interval; // test interval RunTime.Enbled = true; //set timer to true //QBridge bridge_object = new QBridge(); //bridge_object.SendNotification("start"); //SendNotification("start"); } protected override void OnStop() { RunTime.Enabled = false; RunTime.Dispose(); try { bridge_object.SendNotification("stop"); } catch (NullReferenceException nre) { System.Windows.Forms.MessageBox.Show("Error " + nre); } catch (Exception er) { System.Windows.Forms.MessageBox.Show("Error " + er); } //SendNotification("end"); } //Included this to test locally. works fine when just calling the method protected void RunTime_Elapsed(object source, ElapsedEventArgs e) { //SendNotification("run"); try { bridge_object.SendNotification(run); } catch (NullReferenceException nre) { System.Windows.Forms.MessageBox.Show("Error " + nre); } catch (Exception er) { System.Windows.Forms.MessageBox.Show("Error " + er); } } public void SendNotification(string email_text) { MailMessage initial = new MailMessage(); initial.Bcc.Add(new MailAddress("")); initial.From = new MailAddress(""); initial.Subject = "Web notification"; initial.IsBodyHtml = true; initial.Body = email_text; SmtpClient mailClient = new SmtpClient("192.168.1.1"); try { mailClient.Send(initial); } catch (Exception ex) { } } } Class using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Net.Mail; using System.IO; using System.Configuration; using System.Data.SqlClient; using System.Data; namespace Intake { public class QBridge { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); private string login_error; public QBridge() { } public void SendNotification(string email_text) { MailMessage initial = new MailMessage(); initial.Bcc.Add(new MailAddress("")); initial.From = new MailAddress(""); initial.Subject = "Web notification"; initial.IsBodyHtml = true; initial.Body = email_text; SmtpClient mailClient = new SmtpClient("192.168.1.1"); try { mailClient.Send(initial); } catch (Exception ex) { } } } }
I am working on a 3-tier asp.net application. Currently I'm stuck up in a situation where I need to handle a specific type of exception (User Defined) in DAL and Show alert to the user if that exception occurs in DAL.
I tried following things:
1) I raised that exception from the DAL and catch it in BLL and throw a new BLL exception to for that DAL exception and finally catch it in the UI layer to show the alert to the user. I've successfully implement this in my project. But there are some issues in this approach. First of all I feel this is not right way to do this as it may lead to performance related issues. Secondly, the application contains more than 500 pages and classes. so I need to attach additional catch block in every method to catch the BLL exception. which is the last option i'd like to take.
2) in second approach I logged the the DAL exception into a text file. but problem in this approach is that how could the UI layer know that exception has occurred and show the alert to the user. Is there any event in asp.net where i could handle all this activities?
my question is what is the best approach to handle this type of situation? Will Exception handling block help me in this?
I've tried reading many articles on this but i couldn't get an answer for my question? I might not be using right keywords for my search.
In ASP.NET,How can i know the Specific details about an exception (like What kind of Exception it is (FileNotFound /Arithmentc etc..) )from a General Exception class object.
3. Data Access Layer to do the dealing with the database.
Now i have a Contacts page from where i can add a new contact to the database.So to add a New Contact i fill in all the required details and then call a Add Method (residing in the BLL) from the page, which in turn call a Add Method residing in the DAL.this method in the DAL returns the Current Identity of the record which is then return back to the BLL method and finally delivered on the page.this is fine. but what if a get an exception how do i handle it properly because the method in DAL has a return type of int and i dont want to throw another error!! coz other wise i will have to write try catch in almost all the methods.
//something like this public int AddMethod(ContactClass contactObj) { int result = 0;[code]...
rather i want to show the user a user-friendly message which they can easily understand and in the mean while i will send a mail to myself documenting the Error that just occurred.how can i implement my custom exception classes.
Is there any way to uniquely identify a particular exception from the general exception class.
i.e any property or method that retrieves a unique identifier that to identify a particular exception.
I have kept some error values and corresponding error texts in an xml file. I want to read that xml file and have to taken the error ids and fix the corresponding texts to a label. in the case of a system exception we have to identify a particular exception.
We're getting this InternalSubStringWithChecks exception with our application's healthMonitoring. This exception is like the Padding is invalid and cannot be removed exception where it's being recorded and we're getting a notification email but the end user is unaware that an actual error has happened. Though we don't want our event log filled up with this rubbish! The stack trace is:
Parameter name: length at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest [code]...
I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I required to add new console application to the existing solution in which I call data layer methods for retrieving data from DB but I get an exception "The type initializer for threw an exception."When I debugged I found that the exception is thrown at datalayer on first line of class where I get connectionstring from
web.config, the code is public static readonly string CONNECT_STRING =
Now if I hardcode the connection string value like public static readonly string CONNECT_STRING = "Data Source=XYZ;uid=sa;password=XXX;initial catalog=ABC;"
it works fine.I don't understand what is the issue here as web application works fine with this datalayer.
In general I want to know what is the difference between bug and exception? If I need to be specific for a particular framework then I would like to go with .Net.
I created a simple data access layer in the dll and reference it in my web app. How can I point the error to the user that his code in this line has an exception. currently, when i input a nonexisting table it will popup an error "invalid object name table_name" and points the my code throw exception inside my dll. I want it to point out to the user code that uses my function that creates an error.
Line 92: Dim ds As DataSet = DAL.Dal.ExecuteDataset("SELECT * FROM table_nam", "DBConnectionString")
I am trying to catch an exception but occasionally get an inner exception. I want to output both into a label. I often get Object reference not set to instance of an object if there is no inner exception.
Catch ex As Exception exError = ex.Message.ToString If Not ex.InnerException.Message Is Nothing Then exError &= "<br/>" & ex.InnerException.Message.ToString End If Return View() End Try
As far as I can see, whenever a filter's OnActionExecuted is called, it might be after an exception has been thrown futher down the request processing pipeline. So surely this means that one should always be checking to see if there's an exception in the filter's context within an implementation of OnActionExecuted?
Isn't this like pre-exceptions error handling where one would have to, say, check the result of a method call to determine if there'd been an error - of course opening up the possiblity that one might forget to do this?
I'm handling exceptions in the Application_Error() method in Global.asax but ex.Source is not giving me much. I want to know where the error occured i.e. /folderName/pageName.aspx.
Also I use lots of user controls so getting aspx name may not even be enough. Is there a way to get the name of object where the exception occured i.e. class name, user control name, etc.
What is the point of throwing an exception? It it anyways going to be caught in the Global.asax Application_Error method.
Lets say in the following code we throw an exception.
try { using (var dc = GetDataContext()) { // We are doing some data inserts here. } catch ( Exception ex) { throw ex; }
My Question: Even if we do not use try catch and throw here, any exception which will be raised here will be caught inside Application_Error method in Global.asax. Then what is the point of try, catch and throw in this case?
I'm developing a .NET application using .NET 3.5 .My application is using a JAVA
WebService (wsdl url)
When I run the application I want to consume the web service (wsdl file) written in XML. i either keep getting the Operation Time out Error or the following exception while debugging
Possible SOAP version mismatch: Envelope namespace
We have a web application based on asp.net 1.1. We deployed it on a web server but there is a problem about it. In the webserver sometimes cpu usage is increasing to 100% and outofmemory exception is occuring.
I think there are some wrong code inside the project but i don't know where it's.
Now, i want hear your advices about how to find problem and what kind of codes make cpu usage increased.