how to use try/catch inside a DLL

I can put "try/catch " in any MFC application and console application,

when I make a DLL,

#include "extcode.h"
#include <ole2.h>
#include <stdio.h>
#include <conio.h>
#include <winbase.h>

_declspec(dllexport) char Go(.....)
{
         try
       {

        }
       catch(...)
     {
      }
}

it says

undeclared identifier

if I put     #include stdafx.h

it also can't compile

how can I get try/catch work inside my VC DLL ?

thanks very much


0
yzhu1 (7)
2/7/2005 10:20:16 PM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
1211 Views

Similar Articles

[PageSpeed] 14

Does your DLL have the build settings set to allow C++ exceptions?

0
jmoleary (3)
2/7/2005 10:24:46 PM
no, could you tell me where I can set it in VC?

<jmoleary@earthlink.net> wrote in message
news:1107815086.476626.82740@z14g2000cwz.googlegroups.com...
> Does your DLL have the build settings set to allow C++ exceptions?
>


0
yzhu1 (7)
2/7/2005 11:14:26 PM
In VC6.0

    Goto Project->Settings ( Alt+F7 ) and select the 'C++' tab.
    Select "C++ language" from the category combobox.
    Check the box titled 'Enable exception handling'

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

"richard" <yzhu@algis.ca> wrote in message
news:110ftle64v8apfd@corp.supernews.com...
> no, could you tell me where I can set it in VC?
>
> <jmoleary@earthlink.net> wrote in message
> news:1107815086.476626.82740@z14g2000cwz.googlegroups.com...
> > Does your DLL have the build settings set to allow C++ exceptions?
> >
>
>


0
CheckAbdoul
2/7/2005 11:21:23 PM
yes, that one has been checked,
it still saya
error C2065: 'try' : undeclared identifier


"CheckAbdoul" <checkabdoul at mvps dot org> wrote in message
news:ej8D9uWDFHA.1564@TK2MSFTNGP09.phx.gbl...
> In VC6.0
>
>     Goto Project->Settings ( Alt+F7 ) and select the 'C++' tab.
>     Select "C++ language" from the category combobox.
>     Check the box titled 'Enable exception handling'
>
> -- 
> Cheers
> Check Abdoul [VC++ MVP]
> -----------------------------------
>
> "richard" <yzhu@algis.ca> wrote in message
> news:110ftle64v8apfd@corp.supernews.com...
> > no, could you tell me where I can set it in VC?
> >
> > <jmoleary@earthlink.net> wrote in message
> > news:1107815086.476626.82740@z14g2000cwz.googlegroups.com...
> > > Does your DLL have the build settings set to allow C++ exceptions?
> > >
> >
> >
>
>


0
yzhu1 (7)
2/7/2005 11:30:38 PM
there is no such thing as a message that says "undeclared identifier" without naming the
identifier. It would help a lot if you gave the actual error message and not some handwave
about it.  Note that you have omitted all sorts of important information about this error,
such as the name of the file that contains it! (For example, if your .dll file is a .c
file then you can't use C++ try/catch in it, for starters). And why are you including
somehting like winbase.h, when the correct approach is to include windows.h, and better
still, do it as a precompiled header? Or do you enjoy long compilations? 
				joe

On Mon, 7 Feb 2005 14:20:16 -0800, "richard" <yzhu@algis.ca> wrote:

>I can put "try/catch " in any MFC application and console application,
>
>when I make a DLL,
>
>#include "extcode.h"
>#include <ole2.h>
>#include <stdio.h>
>#include <conio.h>
>#include <winbase.h>
>
>_declspec(dllexport) char Go(.....)
>{
>         try
>       {
>
>        }
>       catch(...)
>     {
>      }
>}
>
>it says
>
>undeclared identifier
>
>if I put     #include stdafx.h
>
>it also can't compile
>
>how can I get try/catch work inside my VC DLL ?
>
>thanks very much
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/7/2005 11:38:44 PM
the whole message like : error C2065: 'try' : undeclared identifier




"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:9quf01l1lfj1aaf9hcsikimuvfdrl239gu@4ax.com...
> there is no such thing as a message that says "undeclared identifier"
without naming the
> identifier. It would help a lot if you gave the actual error message and
not some handwave
> about it.  Note that you have omitted all sorts of important information
about this error,
> such as the name of the file that contains it! (For example, if your .dll
file is a .c
> file then you can't use C++ try/catch in it, for starters). And why are
you including
> somehting like winbase.h, when the correct approach is to include
windows.h, and better
> still, do it as a precompiled header? Or do you enjoy long compilations?
> joe
>
> On Mon, 7 Feb 2005 14:20:16 -0800, "richard" <yzhu@algis.ca> wrote:
>
> >I can put "try/catch " in any MFC application and console application,
> >
> >when I make a DLL,
> >
> >#include "extcode.h"
> >#include <ole2.h>
> >#include <stdio.h>
> >#include <conio.h>
> >#include <winbase.h>
> >
> >_declspec(dllexport) char Go(.....)
> >{
> >         try
> >       {
> >
> >        }
> >       catch(...)
> >     {
> >      }
> >}
> >
> >it says
> >
> >undeclared identifier
> >
> >if I put     #include stdafx.h
> >
> >it also can't compile
> >
> >how can I get try/catch work inside my VC DLL ?
> >
> >thanks very much
> >
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm


0
yzhu1 (7)
2/8/2005 12:02:37 AM
So you have not answered any of the other questions. It sounds like you are trying to use
a C++ construct in a .c file.
				joe

On Mon, 7 Feb 2005 16:02:37 -0800, "richard" <yzhu@algis.ca> wrote:

>the whole message like : error C2065: 'try' : undeclared identifier
>
>
>
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
>news:9quf01l1lfj1aaf9hcsikimuvfdrl239gu@4ax.com...
>> there is no such thing as a message that says "undeclared identifier"
>without naming the
>> identifier. It would help a lot if you gave the actual error message and
>not some handwave
>> about it.  Note that you have omitted all sorts of important information
>about this error,
>> such as the name of the file that contains it! (For example, if your .dll
>file is a .c
>> file then you can't use C++ try/catch in it, for starters). And why are
>you including
>> somehting like winbase.h, when the correct approach is to include
>windows.h, and better
>> still, do it as a precompiled header? Or do you enjoy long compilations?
>> joe
>>
>> On Mon, 7 Feb 2005 14:20:16 -0800, "richard" <yzhu@algis.ca> wrote:
>>
>> >I can put "try/catch " in any MFC application and console application,
>> >
>> >when I make a DLL,
>> >
>> >#include "extcode.h"
>> >#include <ole2.h>
>> >#include <stdio.h>
>> >#include <conio.h>
>> >#include <winbase.h>
>> >
>> >_declspec(dllexport) char Go(.....)
>> >{
>> >         try
>> >       {
>> >
>> >        }
>> >       catch(...)
>> >     {
>> >      }
>> >}
>> >
>> >it says
>> >
>> >undeclared identifier
>> >
>> >if I put     #include stdafx.h
>> >
>> >it also can't compile
>> >
>> >how can I get try/catch work inside my VC DLL ?
>> >
>> >thanks very much
>> >
>>
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
2/10/2005 12:06:08 AM
Reply:

Similar Artilces:

Using RMS with Web ...
HI I saw in item properties that you can make items as active on web ... So I guess there is ability in RMS to make web store using your inventory ? Am I wrong ? I mean actually It will me able to make at least basic web page for online purchasing ? Anybody can help me in with this ? Cause I can't find any documentation about it . Any Ideas or Liks please ... -- Best Regards Ashot Bayatyan Hello Ashot! If you want, you can talk to me about Nitrosell's web solution for RMS. It's the best one from what I have looked at. Regards, Jack "Ashot" <abayatian@ya...

How to download a file using WebBrowser
Hi, I'm looking for an information: I've got a variable called pView, from a sublcass of "CHtmlView" (for internet-applications within WebBrowser). Is it possible to 1. open a page (.htm) 2. look for a string within that page ? I don't find any information on the second step (such as methods of any of the classes above CHtmlView). The application I'm trying to make is meant for copying one (similar) line from every page in a range of adresses. FOR EXAMPLE: on every page from http://www.mywebpage.com/file00.htm to http://www.mywebpage.com/file99.htm the twe...

Can you save an MDB file using VBA?
I have an Access 2003 application that is typically used for large amounts of data entry in a relatively short period of time by multiple users - all accessing the same back-end MDB file. I am looking for a way to back up this MDB file to a different PC on the network on a regular basis, perhaps by an automatic backup at predefined intervals. This would require some VBA code to save the file. However, I'm struggling to find something suitable. My first thought was to use DoCmd.Save, but that does not seem to apply to a database object. Any suggestions? David David, You can do ...

Excel Security when using external data
I would think the answer is here somewhere but I'm not finding it, so here goes. In Access when a table is linked in and the password is saved it's fairly easy to read the password by opening the MsysObjects table. Does Excel have a similar vulnerability when an external data source is setup? We use a universal login and password and then use another application to prevent people from opening things they shouldn't. If Excel has a similar vulnerability, is there a work-around? So far in my exploring settings, opening the xls file in Notepad, etc I'm not finding the DSN...

trying to create
Trying to create a more functional worksheet that can do multiple tasks. The problem is I need to create a sheet for several jobsites. Each jobsite will have mostly the same basic information. However, sometimes there are other variables. I need to have it so that I can show payments made for certain tasks completed per sheet basically reconcillation per sheet. Then create some sort of summary page that will show specific information pertaining to each jobsite to include total payments made resulting in a final total billed and paid summary. Help! Maybe.... You could have a work...

An easy way to Read and Write to SQL Server using MFC???
I need to know how to read, write, and append records to SQL server in the simplest possible way. It has to be simple because I need to get it to begin to work within one day maximum. I am estimating that some form of ADO would be best. I am using MSVC++ 6.0. Can anyone help me with this? "Peter Olcott" <NoSpam@SeeScreen.com> wrote in message news:kNhii.469741$JN6.200734@newsfe17.phx... > I need to know how to read, write, and append records to SQL > server in the simplest possible way. It has to be simple > because I need to get it to begin to work within one...

use port number for the sql server? while installing CRM 3.0
when installing Microsoft CRM 3.0, can we use port number for the sql server? Responded to on the CRM Deployment forum. -- Rgds Michael MCDBA 2000 | MCITP DBA 2005 "Amit - Techtrends" wrote: > when installing Microsoft CRM 3.0, > can we use port number for the sql server? ...

Using "Like" expression in Parameter Query (Query Tool)
I am trying to use the "Like" expression in a Parameter Query. The correct syntax for this in MS Access is ' Like [user input] & "*" ' When I use this structure in MS Query however (substituting '%' as the wildcard), I get the error message "too few parameters" As usual, the online help isn't much I would be most grateful if someone could provide some assistance here Many Thank Dear Tom I don't know if this will work at all, but I do know that MS query uses single quote marks rather than double - So you may want to revise your sta...

problem when try to store xmldom into hashmap
hi all , I make a object of MSXML2::IXMLDOMDocument2Ptr m_pDocPtr: ANd i call loadxml many times to load different xml string and each time i store m_pDocPtr in to hashmap as value with some key say number.. this mean in hashmap now i have many differnt xmls loaded .(as i load each time different string) but this does't work , but my need is that i have to do like that can anyone help -- amit bharadwaj VC++(ATL,MFC) developer Your DocPtr references the document, not the node you have just loaded. Storing the DocPtr multiple times in your map will therefore not save the s...

Default Printer GP10 Uses Changes in Terminal Server Environment
We have GP10SP3 installed in a terminal server environment. We have had a couple of users report that when they print something from GP, the document goes to the wrong printer even though the local workstation and the terminal sever show the correct printer as the default. We have noticed that when a user logs in to the terminal server, it takes a minute or so for all of the printers to become available. It is our suspicion that the user starts GP before the system is reporting that the default printer is available and GP picks another one to use. Other programs I've tested do no...

Importing data to Excel using a keyboard shortcut
I am trying to bring data into Excel from a web based report. I can easily do this at home by right clicking on the web based data and then "export to Excel". However, at work, the right click mouse function is disabled due to security reasons. Are there any keyboard shortcuts that essentially duplicate the right click, export to Excel function? There are none indicated on the (right click) drop down window when viewed from home. Thanks for your help -- Ken McI Possible idea: On a mjority of newer keyboards, there is a button between the right Alt and Ctrl b...

Detecting Excel 97 using VBA
Hi. I need to detect, in a VBA script, if it is executed by Excel 97. How do I do that? Casper Casper; MsgBox "Welcome to Microsoft Excel version " & _ Application.Version & " running on " & _ Application.OperatingSystem & "!"Shows the version number in a messagebox Mark.-- Meer Excel ? www.rosenkrantz.nl of contact@rosenkrantz.nl------------------------------------------------------ -------------Rosenkrantz Spreadsheet SolutionsWitkopeend 241423 SN UithoornNederlandTel : 0297-527511--------------------------------------------------...

Has anyone got an example of using CAsyncSocket to connect and read/write data to an internet connection?
Never used this before. Trying to put something together quickly (if it's possible). If not, guess I will need to do some reading. Thanks. There are several examples in the MSDN. Using the examples, I put together a TCP handler in an afternoon, never having used CAsyncSocket before. joe On Wed, 19 May 2004 18:02:04 +0100, "Colin Girling" <colin@colingirling.my-bulldog.com> wrote: >Never used this before. >Trying to put something together quickly (if it's possible). > >If not, guess I will need to do some reading. > >Thanks. > Joseph M. N...

Using Out of Office Assistant with .PST file
Our exchange server is set-up so mail gets delivered to .pst files. I do not want to change to having mail delivered to mailboxes. When employees are going to be out....they set-up the Out of Office Assistant. However, this only seems to work for internal use. If someone from within the exchange server sends an email to this person....they get the reply email back stating that they are out of the office. However, if someone from outside our company sends an email...they don't get the automatic email. Is there a workaround to this? is something not set-up properly on our server? any...

create a visio diagram using an excel spredsheet
Hi, I have an excel spreadsheet with more than 1000 lines. Basically the spreadheet shows all the connections between my network elements, i.e.:Site A connects to Site B with a Capacity C. I want to make a visio drawing showing all the network connections between all the sites and show also the capacity for each connection. The site will be represented by boxes and the connections will be represented by lines with a text showing the capacity. Is there anyway that I can automate this in visio using my excel spreadheet. I'm not very familiar with visio. I only do simple diagrams manu...

How to use Post-Callouts
Hi, I wanted to use the post-callouts option in MS CRM.to get notifications when an account or lead is created. I read the SDK, where it says, we have to create a COM+ service which implements the ICRMCallout Interface. In which DLL does this ICRMCallout Interface is defined. I guess, certainly not in Microsoft.Crm.Proxy.Dll since I already checked in it. Any help would be greatly appreciated Thanks Rojer I don't know if you've checked this article: http://msdn.microsoft.com/library/en-us/dnmbscrm/html/mbs_crmpostcallouts.asp I haven't read it either so I don't know ...

benefit of using OPOS versus windows driver
hey , can somebody please tell me what are the benefits of using OPOS driver with RMS rather than just using windows driver thank you shoby Personally I have way way better luck getting Windows Drivers to work than OPOS and I find overall you have more control. Having said that now guys that have been around for a while (lets call them dinosaurs) and have been doing this for 20 years are going to say that OPOS is the way to go. Rob "Shoby" wrote: > hey , > > can somebody please tell me what are the benefits of using OPOS driver with > RMS rather than just usi...

Using money on another computer
I am using Microsoft Money 2003 D&B. I have my computer networked with my secretaries computer. I want her to pay my bills on her computer. I tried installing money 2003 on her computer (after uninstalling on mine) and it appeared to install properly but when I try and start it using the desktop icon that was installed it pops on and then off with no error message. I use Windows 98 on her computer as there are some old programs I use that only work on that operating system. Any solutions or suggestions. Also is there anyway to use this program over the network so that it ca...

Need help with using Month as criteria for SUM(COUNTIFS(...
Hi all, I am fairly new to excel and experimenting some functions with my project. I have a SOLD datasheet with Sold Date (column W) in MM/DD/YYYY format). I am trying to count the items with a few criteria using =SUM(COUNTIFS(criteria_range1, criteria1, criteria_range2, criteria2,...criteria_rangeN, criteriaN)) Current formulas are working without any problem. Now, i want to narrow down by months and found out that MONTH functions does not work with current formulas. So i tried adding IF function in front of the current formula Jan=1, Feb=2, ... , Dec = 12 =IF(MONTH(SOLD!W:W)=1, SUM(CO...

I've never used Outlook 2007? What's the best way to get started?
I need to learn Outlook quickly. The online tutorials I've seen seem more geared to someone who has used an earlier version of Outlook before. I need a "Dummies"-type tutorial. Help, please! Job seeker wrote: > I need to learn Outlook quickly. The online tutorials I've seen seem more > geared to someone who has used an earlier version of Outlook before. > I need a "Dummies"-type tutorial. Help, please! Double click on the Outlook icon. Follow the simple directions. Alias there is a dummies book... my preferred method is to play with it, check out ...

Use my Exchange as Front and Back End
This is a multi-part message in MIME format. ------=_NextPart_000_001B_01C708A9.48A5A920 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable How i can put my server to be use as End and Front End. I need to activate the web option for my users. When I try to check the box for Front End it says Cannot be both Back = and Front End. How I can solve that. Rafael ------=_NextPart_000_001B_01C708A9.48A5A920 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3...

Using Outlook 2003 with Office XP
I have gone through multiple messages regarding the use of Outlook 2003 and the remaining components of Office XP, but I am unable to get a clear cut answer regarding their compatibility, recommended installation flow etc. I am using an authoring systems which requires Word Xp and Powerpoint XP, however I'd like to be able to use Outlook 2003 (the authoring system does not require a specific Outlook version!). My questions are: (i) Can I install Office XP without the Outlook component (i.e., Word, Powerpoint etc.), and following that install just the Outlook component from the Off...

using a reference # on a check along with an account
I pay several bills and have several diffrent accounts at a credit union that gives me one account # and a reference # for each seperate area in my acount. As near as I can see money doesn't allow for a memo area when you pay bills online. any tips on how to handle this problem? thanks If your credit union is like mine, every transaction out in the clearing house system refers, by definition, to one draft account under the master account number. Just like the MICR account number on your checks omits the separate account designator and just has the master account number. "morty s...

Import Excel to GP table using Dexterity
Hello all, Does anyone knows how to import excel datas in to GP table using Dexterity? If possible provide any sample code for this. Regards, Prakash Prakash, You should be able to read a file name with the SanScript GetFile function and define a Data Type as Reference, using a Reference Type of COM Object, and defining the COM Object Type as Excel.Application object. I do not have any samples at this time, but I am sure you can figure it out with the Dexterity Programmer's Guide. Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http:/...

Outlook 2003 locks up when trying to receive mail
We are running small business server 2003 and used all the wizards to set up exchange. We have two tablet PCs both running XP, only one computer is experiencing this problem. When connected to the internet, but not to the network or exchange (this computer is a sales person who is never in the office and not VPNed in) when they try to use outlook 2003 to send or receive mail (POP mail) it tries to connect to the server then locks up. I have tried logging in as this person on my tablet PC while not connected to the network and it opens and sends and recieves fine. I have compared user permi...