How to handle COM Exception

This is a discussion on How to handle COM Exception within the C# Programming forums, part of the General Programming Boards category; hi guys , simple code to convert from text to speech .. it's supposed to work fine . any way ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    4

    Question How to handle COM Exception

    hi guys ,

    simple code to convert from text to speech .. it's supposed to work fine .
    any way it generates a COM exception isn't handled .

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using SpeechLib;
    
    namespace SimpTesTX
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                string s = "Hello World ";
                SpVoice sp = new SpVoice();
              
                sp.Speak(s, SpeechVoiceSpeakFlags.SVSFDefault);
               
    
           }
        }
    }
    thanx is advance .

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You handle COM exceptions like any other exception: by catching it.

    To solve your problem, you would want to know what the exact error is. Catching the exception and printing out its message will help you there.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 05:02 PM
  2. Handle C++ exception and structured exception together
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-24-2008, 09:21 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21