473,804 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception causes access violation

Hi,

I have a mind boggling error in VC++ .NET.

An exception THException is being thrown, but it seems to cause an
accessviolation , but the code is so simple that I cant figure out where the
av comes from.
MyMesh::Point cog()
{
if (fCount != 0)
return fCoG/fCount;
else
throw THException("Th ere were no vertices to average...");
<--- this gets thrown
}
class THException
{
public:
THException(str ing msg){fMsg = msg;}
string getMessage(){re turn fMsg;}
protected:
private:
string fMsg;
};
try
{
...
mesh.cog()
...
}
catch(THExcepti on e)
{
cerr << "EXCEPTION: " << e.getMessage() << endl;
exit(1);
}
catch(...)
{
cerr << "EXCEPTION: " << "Unknown Exception caught..." << endl;
exit(1);
}
OUTPUT:
First-chance exception at 0x77e73887 in SphericalParame terization.exe:
Microsoft C++ exception: THException @ 0x0012f9d8.
First-chance exception at 0x004f1bbc in SphericalParame terization.exe:
0xC0000005: Access violation reading location 0xcdcdcddd.
Jul 19 '05 #1
1 5826

"Toon Huysmans" <to**@ruca.ua.a c.be> wrote in message news:3f******** @news.ruca.ua.a c.be...
Hi,

I have a mind boggling error in VC++ .NET.
Try this in micrsoft.public .vc.language. It looks fine from a C++ point of
view (provided all those spurious copies of string don't throw).

CDCDCDCD is the debug mode "fill" pattern for uninitialized memory.
Are you sure the compile options you have specified allow exceptions?
I don't know about .NET, but VC6 you had to specifically enable exception
handling (and even then there were some bugs in it).
class THException
{
public:
THException(str ing msg){fMsg = msg;}
How aboiut
THException(con st string& msg) : fMsg(msg) { }
catch(THExcepti on e)


If you ever derive from THException, would be better to catch by reference here.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
24181
by: batista | last post by:
Hi, I am getting the following exception First-chance exception in TestMansoor.exe: 0xC0000005: Access Violation When i run the following code 1 int main(void) 2 {
4
15841
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
44
4235
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
3
6324
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql, which is called once the user clicks the OK button on this dialog. try { int rows = cmd.ExecuteNonQuery(); } catch(SqlException se)
5
2451
by: InNeedOfHelp | last post by:
I am using VC++ 6, I am trying to add a CBitmapButton to a dialog, I followed the steps from the web page below. I got the bitmap button working but when I exit the dialog box a message appears saying 'Unhandled exception in ModelWizard.exe: 0xC0000005: Access Violation.' I'm new to programming/MFC and this has me stumped - any help would be greatly app. Thanks http://www.codersource.net/mfc_bitmap_button.html
2
24527
by: Abubakar | last post by:
Hi all, I'm writing an app in vc++ 2k5 (all native/unmanaged). This application does a lot of multithreading and socket programming. Its been months since I'm developing this application, at this point a lot of it is working just fine, my app running fine, threads r being made and destroyed, memory is being dynamically allocated at God knows how many places and ,hopefully, getting deallocated as well. Its just by coincedence I happened...
3
3936
by: Sebastian M. Rouaiha | last post by:
Hi. I have a problem. When drawing into a graphics context I sometimes get access violation exceptions and I can't figure out why. It seems to have to do with the use of custom dashes. If I change the dash I get the exception. Following is a code example: Pen pLine = new Pen(colBkg); // colBkg is a valid color // fill area with background color. g is a valid graphics context
1
5993
by: kreator | last post by:
Hi i got an Access Violation error with AnsiStrings n char*. First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 0040467E in module 'Serial.exe'. Write of address 0518F503'. Process Serial.exe the code is here: AnsiString temp = Hex2Ascii(APDUCmd, index);
13
26674
by: ycinar | last post by:
A quick question: Why doesn't the following code catch the Access violation reading location exception? it crashes on line if ( xyz ) with an Access violation reading location exception. Is not catch supposed to catch it? Practically, it doesnt. try { if ( xyz ) // crashes here {
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.