473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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("There were no vertices to average...");
<--- this gets thrown
}
class THException
{
public:
THException(string msg){fMsg = msg;}
string getMessage(){return fMsg;}
protected:
private:
string fMsg;
};
try
{
...
mesh.cog()
...
}
catch(THException e)
{
cerr << "EXCEPTION:" << e.getMessage() << endl;
exit(1);
}
catch(...)
{
cerr << "EXCEPTION:" << "Unknown Exception caught..." << endl;
exit(1);
}
OUTPUT:
First-chance exception at 0x77e73887 in SphericalParameterization.exe:
Microsoft C++ exception: THException @ 0x0012f9d8.
First-chance exception at 0x004f1bbc in SphericalParameterization.exe:
0xC0000005: Access violation reading location 0xcdcdcddd.
Jul 19 '05 #1
1 5785

"Toon Huysmans" <to**@ruca.ua.ac.be> wrote in message news:3f********@news.ruca.ua.ac.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(string msg){fMsg = msg;}
How aboiut
THException(const string& msg) : fMsg(msg) { }
catch(THException 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
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
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
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...
3
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,...
5
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...
2
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...
3
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...
1
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...
13
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.