470,848 Members | 1,817 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

Bizzare error following change of _export to __declspec(dllexport)

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
Mar 1 '06 #1
7 1753
>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
Mar 1 '06 #2
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" <ma*************@newsgroups.nospam>
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: <eJ**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.vc
NNTP-Posting-Host: host217-34-108-233.in-addr.btopenworld.com 217.34.108.233Path: TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.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 toVS2005. 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


Mar 2 '06 #3
"David Lowndes" <Da****@example.invalid> wrote in message
news:n1********************************@4ax.com...
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?


Yep. And the app run's fine despite the error.

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


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

Martin
Mar 2 '06 #4
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"" <v-******@online.microsoft.com> wrote in message
news:Gh**************@TK2MSFTNGXA03.phx.gbl...
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" <ma*************@newsgroups.nospam>
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: <eJ**************@TK2MSFTNGP10.phx.gbl>
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!TK2MSFT NGP10.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

Mar 2 '06 #5
>Any ideas where I can find out how to debug the registration process of the
dll?


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
Mar 2 '06 #6
Cheers,

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

Martin

""TerryFei"" <v-******@online.microsoft.com> wrote in message
news:I7**************@TK2MSFTNGXA03.phx.gbl...
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" <ma*************@newsgroups.nospam>
References: <eJ**************@TK2MSFTNGP10.phx.gbl>

<Gh**************@TK2MSFTNGXA03.phx.gbl>
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: <#S**************@TK2MSFTNGP15.phx.gbl>
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!TK2MSFT NGP15.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"" <v-******@online.microsoft.com> wrote in message
news:Gh**************@TK2MSFTNGXA03.phx.gbl...
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" <ma*************@newsgroups.nospam>
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: <eJ**************@TK2MSFTNGP10.phx.gbl>
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!TK2MSFT NGP10.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 registryOK, so not sure if it's related. If it is, how do I fix it?!

Any ideas? I do not have a clue!

Martin


Mar 3 '06 #7
Ta,

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

Thanks for your help,

Martin

"David Lowndes" <Da****@example.invalid> wrote in message
news:at********************************@4ax.com...
Any ideas where I can find out how to debug the registration process of
the
dll?


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

Mar 3 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Marco [Stinger] | last post: by
2 posts views Thread by Luis | last post: by
1 post views Thread by =?Utf-8?B?RmFiaWFu?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.