CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    1

    Question set the outputpath and assemblyname appropriately to point at the correct...

    hello every body, please help,
    when i compile my project it gives me this error:
    "C:\users\Craig\documents\visual studio 2008\projects\sqrroot\sqrroot\bin\Debug\sqrroot.exe' is missing.
    please build the project and retry, or set the outputpath and assemblyname appropriately to point at the correct location for the target assembly."

    it gives me also the errors list:
    "The type or namespace name 'NegativeNumberException' could not be found (are you missing a using directive or an assembly reference?"
    ---------------

    here is my code of sqrroot.cs:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace sqrRoot
    {
    public partial class sqrRoot : Form
    {
    public sqrRoot()
    {
    InitializeComponent();
    }
    protected override void Dispose(bool disposing)
    {
    if (disposing)
    {
    if (components != null)
    {
    components.Dispose();
    }
    }

    base.Dispose(disposing);
    }



    static void Main()
    {
    Application.Run( new sqrRoot() );
    }

    // computes the square root of its parameter; throws
    // NegativeNumberException if parameter is negative
    public double SquareRoot( double operand )
    {
    // if negative operand, throw NegativeNumberException
    if ( operand < 0 )
    throw new NegativeNumberException(
    "Square root of negative number not permitted" );

    // compute the square root
    return Math.Sqrt( operand );

    } // end class SquareRoot

    // obtain user input, convert to double and calculate
    // square root
    private void button1_Click_1(
    object sender, System.EventArgs e )
    {
    Label1.Text = "";

    // catch any NegativeNumberExceptions thrown
    try
    {
    double result =
    SquareRoot( Double.Parse( TextBox1.Text ) );

    Label1.Text = result.ToString();
    }

    // process invalid number format
    catch ( FormatException notInteger )
    {
    MessageBox.Show( notInteger.Message,
    "Invalid Number Format", MessageBoxButtons.OK,
    MessageBoxIcon.Error );
    }

    // display MessageBox if negative number input
    catch ( NegativeNumberException error )
    {
    MessageBox.Show( error.Message, "Invalid Operation",
    MessageBoxButtons.OK, MessageBoxIcon.Error );
    }

    }


    } // end class SquareRootTest
    }



    and here is my code of NegativeNumberException.cs:


    // Fig 11.4: NegativeNumberException.cs
    // NegativeNumberException represents exceptions caused by
    // illegal operations performed on negative numbers.
    using System;

    namespace NegativeNumberSquareRoot
    {
    /// <summary>
    /// NegativeNumberException represents exceptions caused by
    /// illegal operations performed on negative numbers
    /// </summary>
    class NegativeNumberException : ApplicationException
    {
    // default constructor
    public NegativeNumberException()
    : base("Illegal operation for a negative number")
    {
    }

    // constructor for customizing error message
    public NegativeNumberException(string message)
    : base(message)
    {
    }

    // constructor for customizing error message and
    // specifying inner exception object
    public NegativeNumberException(
    string message, Exception inner)
    : base(message, inner)
    {
    }

    } // end class NegativeNumberException
    }

  2. #2
    Join Date
    Dec 2011
    Posts
    61

    Re: set the outputpath and assemblyname appropriately to point at the correct...

    declare NegativeNumberException class as public

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured