Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dll- library raising exception class EAccessViolation

Status
Not open for further replies.

Shawnasie

Programmer
Aug 19, 2008
23
0
0
US
I am using CodeGear RAD Studio Borland Builder C++. I have a dll file that I have linked implicitly. I want to be able to use the classes and functions inside this library, but everytime I try, I get a first chance exception at run time stating, "Exception class EAccessViolation with message 'Access violation at address 0040224E in module...'".

I have tried linking explicitly with the same outcome.

Here is the code from my .cpp file.

Code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TMainIFace *nitf;

   TTextIFace *text = nitf->AddText();
   char szbuf[] = "my nitf text block";
   text->AddData(szbuf, strlen(szbuf));

   nitf->Write("test_nitf.ntf");

   delete nitf;
}

And here is some of the virtual code from the dll.

Code:
class TTextIFace : public TBaseObjectIFace
{
public:
   virtual TTextIFace& operator=(const TTextIFace& seg) = 0;
   virtual TTextHeaderIFace* const Header() = 0;
   virtual const char* Data() = 0;
   virtual unsigned int DataSize() = 0;
   virtual unsigned int Size() = 0;
   virtual void Delete() = 0;

   [COLOR=red]virtual void AddData(const char* AData, unsigned int ASize) = 0; [/color]

   //user associated data can go here
   virtual void SetObject(void *AObj) = 0;
   virtual void* GetObject() = 0;
};
class TMainIFace : public TBaseObjectIFace
{
public:
   virtual ~TMainIFace() { };
   virtual TMainIFace& operator=(const TMainIFace& seg) = 0;
   virtual TImageIFace* const AddImage() = 0;
   [COLOR=red] virtual TTextIFace* const AddText() = 0; [/color]
   virtual TSymbolIFace* const AddSymbol() = 0;
   virtual TLabelIFace* const AddLabel() = 0;
   virtual TDESIFace* const AddDES() = 0;

   virtual TRESIFace* const AddRES() = 0;
   virtual TMainHeaderIFace* const Header() const = 0;
   [COLOR=red]virtual int Write(const char* AFilename) = 0;[/color]
   virtual unsigned int Size() = 0;
   //contains other functions not shown
};

Does anyone have any idea why I am getting this exception? Do you think it would be better to link explicitly?
 
So, I figured out there was a problem with the dll I was using. Sorry if I wasted anyone's time.
 
Congratulations! Access violations are a royal pain to find.



James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top