Can't start Excel from C# due to a security exception

C

CodeMan7777

I have written some simple code to open Excel in C#, but for some reason a
SecurityException is thrown instead.

MSExcel.Application xl;

xl = new MSExcel.Application();

The code compiles fine, but never executes well at runtime giving only:

An unhandled exception of type 'System.Security.SecurityException' occurred
in TestApp02.exe

Additional information: Security error.

Does anyone have an idea as to what I am missing? I have written similar VB6
code using GetObject(), but I can't remember ever coming accross a similar
security issue.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?Q29kZU1hbjc3Nzc=?=,

1. Is this running from a Console app, Win form app, something else? Debugging
(F5) or other?

2. if you put it in a try...catch block do you get any more information about
the exception?

3. Version of Excel you're trying to automate?
I have written some simple code to open Excel in C#, but for some reason a
SecurityException is thrown instead.

MSExcel.Application xl;

xl = new MSExcel.Application();

The code compiles fine, but never executes well at runtime giving only:

An unhandled exception of type 'System.Security.SecurityException' occurred
in TestApp02.exe

Additional information: Security error.

Does anyone have an idea as to what I am missing? I have written similar VB6
code using GetObject(), but I can't remember ever coming accross a similar
security issue.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top