?
Solved

Which include file defines COleDispatchException?

Posted on 2009-04-11
5
Medium Priority
?
589 Views
Last Modified: 2013-12-14
This seems like a simple question, but I'm having trouble finding the answer.  

I'm developing a Win32 console application that controls a camera through that camera's SDK.  In the SDK documentation it says that camera errors will throw COleDispatchExceptions.  When I try catch the COleDispatchException in Visual Studio 2008, I get the following error message:

error C2061: syntax error : identifier 'DispatchException'

The Visual Studio project is a simple Win32 project, not an MFC project.  Is COleDispatchException only defined in MFC projects?  I tried changing it to an MFC project but ran into other include errors, so I'd rather not go that route.

The syntax of my call is in the code snippet below
try
{
	Connect(driverId); //SDK method that works as long as my camera is turned on
}
catch (COleDispatchException  e) {
	printf("Excpeption connecting to camera: \n");
}

Open in new window

0
Comment
Question by:wdoutre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 500 total points
ID: 24124121
afxdisp.h
Two ways to find out this sort of thing.  
1) Go to the VS directory and use the Windows Explorer to Search for files *.h that include the text (in this case COleDispatchException)
2) Look at the documentation.  The required headers are always listed
   http://msdn.microsoft.com/en-us/library/zdbad761(VS.71).aspx
 
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 24124127
And Yes, it is an MFC object.
What is the Connect function? It does not appear to be a Win32 API function. If I could see the docs on that I could probably tell you how to handle the exceptions it throws.
0
 

Author Comment

by:wdoutre
ID: 24124221
I tried #1, but the machine I'm on is messed up and won't search the hard drive.  Thanks for #2.

I'm now running into problems compiling and/or linking my project though by getting this error:

afxv_w32.h(16) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

I am not explicitly including afxv_w32.h and this error doesn't show up until I include afxdisp.h.  If I edit my include to encapsulate it as shown in my snippet, then I can compile, link, and run successfully.

This seems dangerous, but when looking at windows.h it doesn't do anything unless _WINDOWS_ is not defined, so I guess I'm okay?  I can't see anywhere else that I'm including afxdisp.h and it doesn't occur if I omit that include, so I don't know what's going on.
#ifndef WINVER
	#define WINVER 0x0501 //Windows XP
#endif
 
#ifndef __AFXDISP_H__
	#undef _WINDOWS_	
	#include "afxdisp.h"
#endif
 
#ifndef _WINSOCKAPI_
	#include <winsock.h>
#endif

Open in new window

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 24124455
Is there a reason that you did not answer my question?  
If you are not using other MFC objects, there may be no reason to use MFC.
0
 

Author Comment

by:wdoutre
ID: 24132210
Sorry I didn't answer your question.  I had my comment open for a long time while I walked through things making sure I was covering everything.  When I finally posted your comment had already been there.

The Connect method is to connect to an Olympus digital camera, via USB driver.  

The documentation for the camera's SDK says that it throws either a proprietary error, or a COleDispatchException.  In practice, it throws either the proprietary error (which I can catch fine) or something that is not a COleDispatchException which crashes my program even if I try to catch (...).
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question