473,785 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception class EAccessViolatio n

1 New Member
Hi

i got an Access Violation error with AnsiStrings n char*.

First chance exception at $7C812A5B. Exception class EAccessViolatio n with message 'Access violation at address 0040467E in module 'Serial.exe'. Write of address 0518F503'. Process Serial.exe

the code is here:

Expand|Select|Wrap|Line Numbers
  1. AnsiString temp = Hex2Ascii(APDUCmd, index);
  2.  
  3. AnsiString Hex2Ascii(char *Hex, unsigned int HexLen)
  4. {
  5.     char *AsciiChar = "0";
  6.     AnsiString temp;
  7.     Hex2Ascii(Hex, AsciiChar, HexLen);
  8.     temp = AsciiChar;
  9.     return temp;
  10. }
actually i hav another Hex2Ascii function:
Expand|Select|Wrap|Line Numbers
  1. AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen)
  2. {
  3.     char *AsciiChar = "0";
  4.     char *HexChar = HexAnsi.c_str();
  5.     AnsiString temp;
  6.     Hex2Ascii(HexChar, AsciiChar, HexLen);
  7.     temp = AsciiChar;
  8.     return temp;
  9.  
  10. }
APDUCmd is a char array:
Expand|Select|Wrap|Line Numbers
  1. char APDUCmd[261];
if i call Hex2Ascii with array length less than 53, it calls AnsiString Hex2Ascii(AnsiS tring HexAnsi, unsigned int HexLen) and no error.
if greater than or equal 53, it calls AnsiString Hex2Ascii(char *Hex, unsigned int HexLen) and Access Violation error occurs.

Can anyone help me solve this?
Feb 23 '07 #1
1 5991
sicarie
4,677 Recognized Expert Moderator Specialist
Hi

i got an Access Violation error with AnsiStrings n char*.

First chance exception at $7C812A5B. Exception class EAccessViolatio n with message 'Access violation at address 0040467E in module 'Serial.exe'. Write of address 0518F503'. Process Serial.exe

the code is here:

Expand|Select|Wrap|Line Numbers
  1. AnsiString temp = Hex2Ascii(APDUCmd, index);
  2.  
  3. AnsiString Hex2Ascii(char *Hex, unsigned int HexLen)
  4. {
  5.     char *AsciiChar = "0";
  6.     AnsiString temp;
  7.     Hex2Ascii(Hex, AsciiChar, HexLen);
  8.     temp = AsciiChar;
  9.     return temp;
  10. }
actually i hav another Hex2Ascii function:
Expand|Select|Wrap|Line Numbers
  1. AnsiString Hex2Ascii(AnsiString HexAnsi, unsigned int HexLen)
  2. {
  3.     char *AsciiChar = "0";
  4.     char *HexChar = HexAnsi.c_str();
  5.     AnsiString temp;
  6.     Hex2Ascii(HexChar, AsciiChar, HexLen);
  7.     temp = AsciiChar;
  8.     return temp;
  9.  
  10. }
APDUCmd is a char array:
Expand|Select|Wrap|Line Numbers
  1. char APDUCmd[261];
if i call Hex2Ascii with array length less than 53, it calls AnsiString Hex2Ascii(AnsiS tring HexAnsi, unsigned int HexLen) and no error.
if greater than or equal 53, it calls AnsiString Hex2Ascii(char *Hex, unsigned int HexLen) and Access Violation error occurs.

Can anyone help me solve this?
In your recursive call, you pass it three variables (HexChar, AsciiChar, HexLen), instead of the two that are declared. Other than that, I'm not too sure what might be going on there... Anyone else have an idea?
Feb 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2043
by: dinks | last post by:
Hi, I'm new to C++ and have been assigned a task which i dont completely understand. Any help would be greately appreciated. Here is the problem: The class "linkedListType" use the "assert" facility. I am to get rid of them and replace them with exceptions. I need to create a "linkedListException" class that's declared and implemented in my "linkedListType" class. This class needs to inherit from the base "exception" class and return...
9
8494
by: Allan Ebdrup | last post by:
Hi I'm having a discussion with another programmer about a best practice for thrownig exceptions. I want to create a rich class library with many different exception classes in their own namespace, so they are easy to find with intellisense. He wants to just throw Exception or one of the build in exceptions. Do you have some good arguments for creating your own exception classes even though they are little more than a type strongname and...
4
6411
by: Divick | last post by:
Hi all, I want to subclass std::exception so as to designate the type of error that I want to throw, out of my classes, and for that I need to store the messages inside the exception classes. I want to use std::string to do that so that I don't have to deal with all the hustle of dealing with char *'s but as listed in the page (see link) below, it is not advisable to use std::string in my exception classes. The rational given is not...
2
1161
by: Carl J. Van Arsdall | last post by:
So this is probably a fairly basic question, but help me out because I'm just not lining things up and I'm somewhat new to the world of exception handling. What's the benefit to inheriting an exception from and of the available parent exception classes? Does one subclass have benefits over any other? Most of what I see involves making a new class and inheriting from Exception so that one can have an exception class with a name of...
4
1509
by: michael | last post by:
Hello everybody, I've created for one of my classes a exception class derivated from System.Exception. This exception class is public and lies within my class as inner class. When I throw this exception I can't catch it with its name! When I try to catch it with it's name then the catch-block will be ignored.... So I've made a general catch with System.Exception and printed the runtime type...
6
1173
by: Joel Koltner | last post by:
I have a generic (do nothing) exception class that's coded like this: class MyError(exceptions.Exception): def __init__(self,args=None): self.args = args When I attempt to raise this exception via 'raise MyError' I get an exception within the MyError constructor __init__ as follows: Traceback (most recent call last):
2
2965
by: Bob Altman | last post by:
Hi all, We have a native class modeled after the System::Exception class, and all exceptions that we throw derive from this class. For now this class is quite simple: just Description and InnerException public members. One of these days I'll dig into how to implement a StackTrace property (I assume that this is possible using something like dbghelp.dll, but I've never had the time to look into it). I've recently written a managed...
4
2653
by: amphetaman | last post by:
If I derive my own Exception class from std::runtime_error, do I have to write the destructor even if its body is empty? #include <stdexcept> class Exception : public std::runtime_error { public: explicit Exception(const std::string &description) : std::runtime_error(description) { }
1
1647
by: Tony Johansson | last post by:
Hello! If I want to create my own Exception class which class is the recommended class to derive from. Should it be from Exception or from System.ApplicationException. //Tony
0
9645
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
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9954
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
8979
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
7502
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
5383
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...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.