Bizzare error following change of _export to __declspec(dllexport)

  • Thread starter Thread starter Martin Pritchard
  • Start date Start date
M

Martin Pritchard

Hi,

Sorry for my ignorance, but I'm a bit new to C++.

I've been handed over a C++ app written in VS2002 which I have to convert to
VS2005. Apparently it's been written in a C style, but cannot comment
myself!

Following the conversion I have numerous errors, which following some
digging around turns out to be because _export is obsolete, and
__declspec(dllexport) is the replacement. e.g.

Changed:
extern "C" BOOL _export vcgl_posting_exists(char * Chart, char *VisibleId,
TK_CONF * TkConf);

To:
extern "C" BOOL __declspec(dllexport) vcgl_posting_exists(char * Chart, char
*VisibleId, TK_CONF * TkConf);

I've changed the entries & recompiled under 2005 but I now get 'Invalid
Access to Memory Location" when trying to register it. To make sure I
compiled the same source (with the changes) under VS2002 and it gave me
exactly the same message! So it looks like the 2005 conversion was not
responsible.

Prior to any work, we used to get 'The specified module could not be found'
when registering the dll, but it would still put entries into the registry
OK, so not sure if it's related. If it is, how do I fix it?!

Any ideas? I do not have a clue!

Martin
 
I've changed the entries & recompiled under 2005 but I now get 'Invalid
Access to Memory Location" when trying to register it. To make sure I
compiled the same source (with the changes) under VS2002 and it gave me
exactly the same message! So it looks like the 2005 conversion was not
responsible.

I'd agree.
Prior to any work, we used to get 'The specified module could not be found'
when registering the dll, but it would still put entries into the registry

Had you rebuilt the DLL from the sources you'd been given at that
point?

If not, I'd suspect you've not been given the same source. :(
Any ideas? I do not have a clue!

Rather than guessing, you'll need to debug it - build a debug
configuration and learn to use the debugger.

Dave
 
Hi Martin,
Welcome to MSDN Newsgroup!

In the current situation, I hope you can send me a simplified sample. So I
can repro this problem on my side. I think it's more efficient to get
closer to resolving your issue.
If you have any questions or concerns, please let me know. I am standing by
to help you. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
 
David Lowndes said:
I'd agree.


Had you rebuilt the DLL from the sources you'd been given at that
point?

Yep. And the app run's fine despite the error.
If not, I'd suspect you've not been given the same source. :(


Rather than guessing, you'll need to debug it - build a debug
configuration and learn to use the debugger.

Dave

Any ideas where I can find out how to debug the registration process of the
dll?

Martin
 
Terry, thanks for the prompt response!

Unfortunately the solution is made up of 5 projects, which can't really be
broken up easily. Also, the code is my company's intellectual property blah
blah blah and sending it out of here could probably cost my job...

In general, should _export work exactly the same as __declspec(dllexport)?

Any thing you could suggest on where to start looking for a fix?

Martin

"TerryFei" said:
Hi Martin,
Welcome to MSDN Newsgroup!

In the current situation, I hope you can send me a simplified sample. So I
can repro this problem on my side. I think it's more efficient to get
closer to resolving your issue.
If you have any questions or concerns, please let me know. I am standing
by
to help you. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
From: "Martin Pritchard" <[email protected]>
Subject: Bizzare error following change of _export to
__declspec(dllexport)
Date: Wed, 1 Mar 2006 13:14:49 -0000
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vc
NNTP-Posting-Host: host217-34-108-233.in-addr.btopenworld.com 217.34.108.233
Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.dotnet.languages.vc:54546
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

Hi,

Sorry for my ignorance, but I'm a bit new to C++.

I've been handed over a C++ app written in VS2002 which I have to convert to
VS2005. Apparently it's been written in a C style, but cannot comment
myself!

Following the conversion I have numerous errors, which following some
digging around turns out to be because _export is obsolete, and
__declspec(dllexport) is the replacement. e.g.

Changed:
extern "C" BOOL _export vcgl_posting_exists(char * Chart, char *VisibleId,
TK_CONF * TkConf);

To:
extern "C" BOOL __declspec(dllexport) vcgl_posting_exists(char * Chart, char
*VisibleId, TK_CONF * TkConf);

I've changed the entries & recompiled under 2005 but I now get 'Invalid
Access to Memory Location" when trying to register it. To make sure I
compiled the same source (with the changes) under VS2002 and it gave me
exactly the same message! So it looks like the 2005 conversion was not
responsible.

Prior to any work, we used to get 'The specified module could not be found'
when registering the dll, but it would still put entries into the registry
OK, so not sure if it's related. If it is, how do I fix it?!

Any ideas? I do not have a clue!

Martin
 
Any ideas where I can find out how to debug the registration process of the

Martin,

Assuming this is a normal COM registration you're talking about, all
that happens to register it is that it's run like this:

regsvr32 yourdll.dll

Enter that as the command line/parameter in the debugger settings of
the project, and set a breakpoint on your DLL's DllRegisterServer
function - or let it run till it crashes and see if you can determine
why it crashes.

Dave
 
Cheers,

Thanks for the link! Looking into it now...

Martin

"TerryFei" said:
Hi Martin,
Thanks for your update! :)

Based on my knowledge, there is no difference between _export and
_declspec(dllexport). However I strongly suggest you provide an EXPORTS
entry for that function in your module definition (.DEF) file when we want
to export function from a specified dll.
A module-definition (.DEF) file that is a text file containing one or more
module statements that describe various attributes of a DLL include:
LIBRARY statement statement identifies the .DEF file as belonging to a DLL
EXPORTS statement lists the names of the functions exported by the DLL
DESCRIPTION statement describes the purpose of the DLL (Optional)
LIBRARY "DllLibrary"
EXPORTS
FunName @1

You can get more information about (.DEF) file from the following website:
Title: Exporting from a DLL Using DEF Files
URL:http://msdn2.microsoft.com/en-us/library/d91k01sh.aspx

If you have any questions or concerns, please let me know. I am standing
by
to help you. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
From: "Martin Pritchard" <[email protected]>
References: <[email protected]>
Subject: Re: Bizzare error following change of _export to __declspec(dllexport)
Date: Thu, 2 Mar 2006 09:42:26 -0000
Lines: 92
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vc
NNTP-Posting-Host: host217-34-108-233.in-addr.btopenworld.com 217.34.108.233
Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.dotnet.languages.vc:54587
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

Terry, thanks for the prompt response!

Unfortunately the solution is made up of 5 projects, which can't really be
broken up easily. Also, the code is my company's intellectual property blah
blah blah and sending it out of here could probably cost my job...

In general, should _export work exactly the same as __declspec(dllexport)?

Any thing you could suggest on where to start looking for a fix?

Martin

"TerryFei" said:
Hi Martin,
Welcome to MSDN Newsgroup!

In the current situation, I hope you can send me a simplified sample. So I
can repro this problem on my side. I think it's more efficient to get
closer to resolving your issue.
If you have any questions or concerns, please let me know. I am standing
by
to help you. Thanks for your understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security


--------------------
From: "Martin Pritchard" <[email protected]>
Subject: Bizzare error following change of _export to
__declspec(dllexport)
Date: Wed, 1 Mar 2006 13:14:49 -0000
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vc
NNTP-Posting-Host: host217-34-108-233.in-addr.btopenworld.com
217.34.108.233
Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: TK2MSFTNGXA03.phx.gbl microsoft.public.dotnet.languages.vc:54546
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

Hi,

Sorry for my ignorance, but I'm a bit new to C++.

I've been handed over a C++ app written in VS2002 which I have to
convert
to
VS2005. Apparently it's been written in a C style, but cannot comment
myself!

Following the conversion I have numerous errors, which following some
digging around turns out to be because _export is obsolete, and
__declspec(dllexport) is the replacement. e.g.

Changed:
extern "C" BOOL _export vcgl_posting_exists(char * Chart, char *VisibleId,
TK_CONF * TkConf);

To:
extern "C" BOOL __declspec(dllexport) vcgl_posting_exists(char * Chart,
char
*VisibleId, TK_CONF * TkConf);

I've changed the entries & recompiled under 2005 but I now get 'Invalid
Access to Memory Location" when trying to register it. To make sure I
compiled the same source (with the changes) under VS2002 and it gave me
exactly the same message! So it looks like the 2005 conversion was not
responsible.

Prior to any work, we used to get 'The specified module could not be
found'
when registering the dll, but it would still put entries into the registry
OK, so not sure if it's related. If it is, how do I fix it?!

Any ideas? I do not have a clue!

Martin
 
Ta,

Have entered it in and going to try and debug it.

Thanks for your help,

Martin
 
Back
Top