Which include file defines COleDispatchException?

Posted on 2009-04-11
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
	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

Question by:wdoutre
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
LVL 49

Accepted Solution

DanRollins earned 125 total points
ID: 24124121
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
LVL 49

Expert Comment

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.

Author Comment

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
#ifndef __AFXDISP_H__
	#undef _WINDOWS_	
	#include "afxdisp.h"
#ifndef _WINSOCKAPI_
	#include <winsock.h>

Open in new window

LVL 49

Expert Comment

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.

Author Comment

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 (...).

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

724 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