.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Creating a div by 0 exception error

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
I have a grid that displays all the years sales cost and billing margin (1-(cost/sales)) but it seems on some years there is a cost but no sale and it is giving me a cannot divide by 0 error on running.    how can i make it where if it cannot give the BM then it will say N/A or something instead of erroring out?   Thanks!

View Complete Post

More Related Resource Links

TableLayoutControl exception "Error creating window handle"

I am using a TableLayoutPanel to create a report on a form. The layout is 1 column, with a 
variable number of rows added based on the number of lines in the report. As I step through
a list of reports, the layout is cleared and rebuilt. After a few iterations of this an
exception in CreateHandle is thrown. Several hundred lines are destroyed and created each
time I switch reports.

I can't find a lot of mention of the error I'm seeing. Here is one of the better ones:


tableLayoutPanel1.SuspendLayout(); tableLayoutPanel1.Controls.Clear(); tableLayoutPanel1.RowStyles.Clear(); tableLayoutPanel1.RowCount = 0; tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); tableLayoutPanel1.Controls.Add(header, 0, 0); tableLayoutPanel1.RowCount++; foreach(Measurement meas in list2) { ReportLine line = new ReportLine(meas); line.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 23F)); // "Unable to create window handle" exception here: tableLayoutPanel1.Controls.Add(line, 0, tableLayoutPanel1.RowCount); tableLayoutPanel1.RowCount++; } tableLayoutPanel1.ResumeLayout();

Error while using exception handling block el 4.1


Hi Folks,


i am trying to use tyhe exception handling block of Enterprise library 4.1.


I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.


During runtime I am getting an exception on the HandleException event, The exception is added below:



Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

Error Handling: Throwing Custom Exception Types from a Managed COM+ Server Application


Exception handling semantics in .NET are based on type, so you can create custom exceptions that have their own properties and methods. In .NET, exceptions are first-class citizens, and since they're the built-in error handling mechanism, all .NET-compliant languages must support exceptions. In addition, COM+ services are available to .NET code as Enterprise Services, so you can leverage exceptions in your Enterprise Services design.In this article the author describes custom exceptions, throwing exceptions across COM interop boundaries, and working with Enterprise Services.

Bob DeRemer

MSDN Magazine March 2004

2008 R2 Tuning Advisor reports "Error: Exception encountered(DTAEngine)"

I am encountering an error when I try to use the SQL 2008 R2 Database Engine Tuning Advisor. I create a very simple workload (either by right-clicking a query in SSMS or by loading a file), and click Start Analysis.  In the "Consuming Workload" step DTA aborts, and in the message column displays "Error: Exception Encountered(DTAEngine)". When I click on the error message, I get a dialog box with a title of DTAEngine, and a message "Error: Exception encountered". This is a clean test environment (SQL 2008 R2 Data Center Edition 64-bit, on Windows Server 2008 R2 64-bit, in a VM) against a local database. Any ideas about what the problem is or how to resolve it? See below for detailed version information: 10.50.1600.1 RTM Data Center Edition (64-bit) Database Engine Tuning Advisor      10.50.1600.1 Microsoft Data Access Components (MDAC)      6.1.7600.16385 Microsoft MSXML      3.0 6.0 Microsoft Internet Explorer      8.0.7600.16385 Microsoft .NET Framework      2.0.50727.4952 Operating System      6.1.7600    

Error: A native exception has occurred in my_file.exe

Hello everyone,   This error is occurring with me when I am working with SSCE in my pocket PC. Can anyone tell me why?   Thanks!

"Format exception was unhandled by user" error. . .please help. . urgent!

Hi to all developers. I'm developing a survey site and i got this error 'Format exception was unhandled by user'. .  please help me deal with this. . any help is much appreciated. .here is where the error occured(2nd line):If Not Request.QueryString("DeptCode") Is Nothing Then            Dim DeptCode As Double = Double.Parse(Request.QueryString("DeptCode"))            Session.Add("DeptCode", DeptCode)        Else            Response.Redirect("default.aspx")        End Ifthanks in advanced. .

how can we show error in our application when exception occur in webs service

how can we show error in our application when exception occur in webs service

Error when creating a net.tcp endpoint in wcf

I am trying to create a simple wcf service that has a net.tcp endpoint.  My OS is Vista and I am hosting the service in IIS 7.  I have set my default website binding for net.tcp to "9200:*" and added net.Tcp to my Enabled Protocols in my website hosting the service and the default website.  Here is my Config Values:   <system.serviceModel>     <services>       <service name="FirstWcfService.Service" behaviorConfiguration="ServiceBehavior">         <!-- Service Endpoints -->         <endpoint address="" binding="netTcpBinding" contract="FirstWcfService.IService"             bindingConfiguration="tcpbinding"/>         <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>         <endpoint address="" binding="wsHttpBinding" contract="FirstWcfService.IService"             />         <endpoint address="mexhttp" binding="mexHttpBinding" contract="IMetadataExchange"/>       </service>     </services>     <behaviors>       <serviceBehaviors>         <behavior name="ServiceBehavior">           <!-- To receive exception details in faults for debugging purposes,                set the value below to true.  Set to false befor

Error creating Web Apps

I am getting the following error when I try and create a Web APP. Error An error occurred while getting information about the user FarmAdmin at server ServeName.com: The network path was not found  Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 6ea31cf3-22bd-4e02-b87b-c1b8a1990ab1 Date and Time: 8/30/2010 2:24:55 PM I have set the logging to verbose The Event logs show nothing. The Sharepoint logs show Provisioning of the web application, null, has encountered the following error: System.InvalidOperationException: An error occurred while getting information about the user FarmAdmin at server ServeName.com: The network path was not found at Microsoft.SharePoint.Win32.SPNetApi32.NetUserGetInfo1(String server, String name)     at Microsoft.SharePoint.Administration.SPManagedAccount.GetUserAccountControl(String username)     at Microsoft.SharePoint.Administration.SPManagedAccount.Update()     at Microsoft.SharePoint.Administration.SPProcessIdentity.Update()     at Microsoft.SharePoint.Administration.SPApplicationPool.Update()     at Microsoft.SharePoint.Administration.SPWebApplication.CreateDefaultInstance(SPWebService service, Guid id, String applicationPoolId, SPProcessAccount processA... 6ea31cf3-22bd-4e02-b87b-c1b8a1990ab1 ...ccount, Str

Pass exception details to custom error page.

Hi All, I created a custom error page and update using webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, CustomErrorPage). Its working fine and my custom error page is show if error is occurred. OR We redirect using SPUtility.RedirectToErrorPage("my message"); But I am not able to find my exception details at my custom error page. Is there any way to pass the exception details and other custom information to custom error page?  

Error .Cummunication Exception was unhandle

Hello Friends,   I was downloaded the SCVMM WCF code and made some modification. I got error CommunicationException was unhandle "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."     Please Help me to solve the problem, Regards rajivbirari

Error when creating PK to a column which has dupliacte columns..

The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'table name' and the index name 'PK__column__118068EB'. The duplicate key value is (D1).

Error creating Read Item or Read List operation in Sharepoint Designer 2010

In terms of high-level requirements, I need to pull in lists from a couple of different web apps.  To do this, I’m using SPD 2010 to create an External Content Type for the list of interest.  I’m able to create a SOAP Service or WCF Service connection just fine.  However, when I try to create the external content type and create a Read Item Operation on one of the GetList or any other Get* (or other Update methods for that matter) methods, I get the following error:"The method that your operation is based on has parameters with complex types that do not have default parameterless constructor.  This kind of data source methods cannot be used in Business Data Catalog."I tried defining an operation on the “AddAttachment” method, and that worked just fine.  I also tried providing default values to the listName and viewName parameters when creating the SOAP Service connection, but still get the error.  Same issue with a WCF Service connection as well. Does anyone know if this is a 2010 issue, or am I approaching this requirement incorrectly?  What are other approaches for connecting to lists that reside in a different web app than yours? 

Internal Server Error Exception when Searching (in CoreResultsWebPart::OnInit)

Hello, We are encountering an "Internal server error exception" when we attempt to search. The relevant error in the ULS log is:   CoreResultsWebPart::OnInit: Exception initializing: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader()     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e)   This is occurring on a fresh install of SharePoint Server 2010 Standard Edition running on a single-server farm.  We have tried:   ensuring that hotfix 976462 is installed (it is) ensuring that the "SharePoint Server Search" and "Search Query and Site Settings Service" services are running (they are) removing, then reinstalling the search application (tried, but with no luck) appending ":80" to the host of portion of the search result url to see if we get a different result (we do not) ensuring that the application pool is assigned correctly (it is) restarting the timer service restarting the search service rebooting For the sake of conversation, we'll say the server is named "pharaoh". It has the following AAMs: http://pharaoh:8888, Default Zone  (Central Admin) http://pharaoh, Default Zone   All services and applicati

Creating database throw exception!

When running SQL commands, it throws error information. Why is it? My env :    windows server 2003 64bit     sql server 2008 . Command :   CREATE DATABASE [AdventureWorks2009]     ON (NAME = 'AdventureWorks2009_Data', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2009_Data.mdf', SIZE = 170, FILEGROWTH = 8),     FILEGROUP DocumentFileStreamGroup CONTAINS FILESTREAM ( NAME = FileStreamDocuments, FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents')     LOG ON (NAME = 'AdventureWorks2009_Log', FILENAME = N'E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWorks2009_Log.ldf' , SIZE = 2, FILEGROWTH = 96); GO     Error information:   Msg 5120, Level 16, State 106, Line 1 Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\Documents". perating system error -2147024891: "0x80070005(failed to retrieve text for this error. Reason: 1815)".

Error Creating Site Collection

Hello, I have created a basic claims-based web app in SharePoint 2010. When I try to create a Site Collection, after filling out all the details, I get the following error:   Error  Cannot complete this action. Please try again.  Troubleshoot issues with Microsoft SharePoint Foundation.  Correlation ID: 349b9ae9-7bda-41eb-921a-87974afb289c    I have tried ever which way to try and get it to work, but am still stuck. Any ideas as to why I can't create a Site Collection? Thanks!

Error when creating site collection through programmatically?

hi all, When i am creating SharePoint Site collection through programmatically i am getting an error message. i am using below code...   using (SPSite site = new SPSite("http://servername:7853/")) {   using (SPWeb web = site.OpenWeb()) {   SPWebApplication oweb = web.Site.WebApplication; site.AllowUnsafeUpdates = true;   SPSiteCollection sitecol = oweb.Sites;   SPSite site1 = oweb.Sites.Add("sites/DemoSiteCol", "DemoSiteCol", "Welcome to the Client SiteCol",1033, "STS#0", "Domian\\user", "display name", "user@domian.com");//here i am getting the error message as "Object refernce not set to an instance of an Object". oweb.Update(); } Please tell me why i am getting the error message.... thanks in advance.....
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend