Unable to start excel from .NET C#

  • Thread starter Thread starter Krish
  • Start date Start date
K

Krish

This is my first attempt, please bear.

I referenced Excel 10.0 Object from VS .NET IDE, I think this creates
Interop Object for Excel.

I have the following code.

------code start----

using System;
using System.Runtime.InteropServices;
using Excel;

namespace ConsoleApplication3
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Excel.Application app = new Excel.ApplicationClass();
app.Visible = true;

}
}
}

---code end----

When the start the code I get the following error messages, the build
is OK though.

DefaultDomain': Loaded
'c:\winnt\microsoft.net\framework\v1.0.3705\mscorlib.dll', No symbols
loaded.
'ConsoleApplication3': Loaded 'C:\Documents and
Settings\Administrator\My Documents\Visual Studio
Projects\ConsoleApplication3\bin\Debug\ConsoleApplication3.exe',
Symbols loaded.
'ConsoleApplication3.exe': Loaded 'c:\documents and
settings\administrator\my documents\visual studio
projects\consoleapplication3\bin\debug\interop.excel.dll', No symbols
loaded.
The program '[2604] ConsoleApplication3.exe' has exited with code 0
(0x0).

----

I would really like to know what is going on, Excel is not
instantiated .!

Any help appreciated.
 
Hi Krish,

Just to confirm, do you not see Excel coming up at all,
or does it quickly start up and shutdown the moment
your console app exits. Try inserting a Console.ReadLine()
soon after you create an instance of Excel.Application.

Excel.Application excelApp = new Excel.Application();
excelApp.Visible = true;
Console.WriteLine("Excel up and running now. Press any key to close Excel");
Console.ReadLine();
excelApp.Quit();


Regards,
Aravind C
 
Thanks Aravind, I did notice that the console.readline causes
the cmd window to stay there.

What are the error messages that I included at the bottom of the
message, that say no symbols loaded, is this just a message from the
debugger.

Also when you look at the object browser, you see Excel {} the curly
braces does it mean namespace.

Thanks for your help.
 
Back
Top