Automation Excel 2003

C

Claude

I added a COM reference of Excel 2003 object model so I can
drive Excel from my C# .net application.

I've added code in a button click to write on an Excel worksheet.

When I run my application and click on the button,
the application interrops and an error occurs :

"SecurityException was unhandled"
"Cet assembly n'autorise pas les appelants d'un niveau de confiance partiel."
(sorry for the last one in french, but my IDE is in french) : in english it
would
sound like :
"This assembly does not authorize the appelants of a partial reliable level."

I've tried the exemple found at :
http://support.microsoft.com/default.aspx/kb/302084
but the error occurs again.

Products used :
Microsoft Visual C# .Net 2005 (Microsoft Visual Studio 2005 Pro SP1)
..Net 2.0 Framework
Microsoft Excel 2003 SP2 (Microsoft Office 2003 Pro)

What can I do to make it work ?

Thanks,
Claude
 
R

RvGrah

My french is a bit rusty, but have you enabled trust to Visual Basic
project and set the security settings correctly?

In excel, go to Tools--> Macro-->Security and make sure the level is
*low* enough to allow what you need and on the second tab put a check
mark next to "Trust Access to Visual Basic Project"

Bob
 
C

Claude

I found the source of the problem, but I don't know how to solve it :

The source code of my application is on the network. If I start the
application in debug mode from there, the button that drives Excel doesn't
work, saying that the security level isn't correct (partial trust security
level).

If I copy the source code localy (on my disk) and start the application in
debug mode, the button that drives Excel works fine.

What can I do to make it work over the network !? How can I change trust
level ?
Wich assembly(ies) must be modified : my dll (that uses Excel), my
application (that uses my dll) or the wrapper for Excel
(Microsoft.Office.Interop.Excel.dll) ?

Thanks,
Claude
 
A

Alvin Bruney [ASP.NET MVP]

You have to create a CAS policy that essentially allows the framework to
execute from the network path, ugly but necessary. To confirm that this is
actually the case, from a command prompt turn off cas policy on the machine
(in the relevant framework folder caspol -s off) That should allow the
application to work fine. Follow this link to learn how to configure CAS
policy http://support.microsoft.com/kb/948034

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
 
C

Claude

I tried "caspol -s off", but the error still occur.

Doh !
Claude

Alvin Bruney said:
You have to create a CAS policy that essentially allows the framework to
execute from the network path, ugly but necessary. To confirm that this is
actually the case, from a command prompt turn off cas policy on the machine
(in the relevant framework folder caspol -s off) That should allow the
application to work fine. Follow this link to learn how to configure CAS
policy http://support.microsoft.com/kb/948034

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



Claude said:
I found the source of the problem, but I don't know how to solve it :

The source code of my application is on the network. If I start the
application in debug mode from there, the button that drives Excel doesn't
work, saying that the security level isn't correct (partial trust security
level).

If I copy the source code localy (on my disk) and start the application in
debug mode, the button that drives Excel works fine.

What can I do to make it work over the network !? How can I change trust
level ?
Wich assembly(ies) must be modified : my dll (that uses Excel), my
application (that uses my dll) or the wrapper for Excel
(Microsoft.Office.Interop.Excel.dll) ?

Thanks,
Claude
 
A

Alvin Bruney [ASP.NET MVP]

If you have run caspol from the 2.0 .net framework folder and you still get
the error, then it is not a security error. Running caspol from another
folder, 1.1 for instance would not work. On the other hand, your application
seems to be abnormal in its setup. Why are you running automation code from
a network share? In the typical case, you should have your application and
the interop dll's deployed to the network share but developped and debugged
locally. When you are satisfied that the application works, you deploy it to
the network share. Please explain why you need this setup.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



Claude said:
I tried "caspol -s off", but the error still occur.

Doh !
Claude

Alvin Bruney said:
You have to create a CAS policy that essentially allows the framework to
execute from the network path, ugly but necessary. To confirm that this
is
actually the case, from a command prompt turn off cas policy on the
machine
(in the relevant framework folder caspol -s off) That should allow the
application to work fine. Follow this link to learn how to configure CAS
policy http://support.microsoft.com/kb/948034

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



Claude said:
I found the source of the problem, but I don't know how to solve it :

The source code of my application is on the network. If I start the
application in debug mode from there, the button that drives Excel
doesn't
work, saying that the security level isn't correct (partial trust
security
level).

If I copy the source code localy (on my disk) and start the application
in
debug mode, the button that drives Excel works fine.

What can I do to make it work over the network !? How can I change
trust
level ?
Wich assembly(ies) must be modified : my dll (that uses Excel), my
application (that uses my dll) or the wrapper for Excel
(Microsoft.Office.Interop.Excel.dll) ?

Thanks,
Claude

:

My french is a bit rusty, but have you enabled trust to Visual Basic
project and set the security settings correctly?

In excel, go to Tools--> Macro-->Security and make sure the level is
*low* enough to allow what you need and on the second tab put a check
mark next to "Trust Access to Visual Basic Project"

Bob

I added a COM reference of Excel 2003 object model so I can
drive Excel from my C# .net application.

I've added code in a button click to write on an Excel worksheet.

When I run my application and click on the button,
the application interrops and an error occurs :

"SecurityException was unhandled"
"Cet assembly n'autorise pas les appelants d'un niveau de confiance
partiel."
(sorry for the last one in french, but my IDE is in french) : in
english it
would
sound like :
"This assembly does not authorize the appelants of a partial
reliable
level."

I've tried the exemple found at
:http://support.microsoft.com/default.aspx/kb/302084
but the error occurs again.

Products used :
Microsoft Visual C# .Net 2005 (Microsoft Visual Studio 2005 Pro SP1)
.Net 2.0 Framework
Microsoft Excel 2003 SP2 (Microsoft Office 2003 Pro)

What can I do to make it work ?

Thanks,
Claude
 
C

Claude

Ok, you are right. I shouldn't be developping from the network share. The
reason I'm doing this is because I develop a business library that I need to
share with the other developpers here. My library isn't the problem : I think
it's ok to have it on the network. The actual problem is that my test
application (to test my library) is also on the network and that's the
problem. I'll copy my test application localy and I'm sure it will solve the
problem, considering that it should be so.

Thanks,
Claude

Alvin Bruney said:
If you have run caspol from the 2.0 .net framework folder and you still get
the error, then it is not a security error. Running caspol from another
folder, 1.1 for instance would not work. On the other hand, your application
seems to be abnormal in its setup. Why are you running automation code from
a network share? In the typical case, you should have your application and
the interop dll's deployed to the network share but developped and debugged
locally. When you are satisfied that the application works, you deploy it to
the network share. Please explain why you need this setup.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



Claude said:
I tried "caspol -s off", but the error still occur.

Doh !
Claude

Alvin Bruney said:
You have to create a CAS policy that essentially allows the framework to
execute from the network path, ugly but necessary. To confirm that this
is
actually the case, from a command prompt turn off cas policy on the
machine
(in the relevant framework folder caspol -s off) That should allow the
application to work fine. Follow this link to learn how to configure CAS
policy http://support.microsoft.com/kb/948034

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



I found the source of the problem, but I don't know how to solve it :

The source code of my application is on the network. If I start the
application in debug mode from there, the button that drives Excel
doesn't
work, saying that the security level isn't correct (partial trust
security
level).

If I copy the source code localy (on my disk) and start the application
in
debug mode, the button that drives Excel works fine.

What can I do to make it work over the network !? How can I change
trust
level ?
Wich assembly(ies) must be modified : my dll (that uses Excel), my
application (that uses my dll) or the wrapper for Excel
(Microsoft.Office.Interop.Excel.dll) ?

Thanks,
Claude

:

My french is a bit rusty, but have you enabled trust to Visual Basic
project and set the security settings correctly?

In excel, go to Tools--> Macro-->Security and make sure the level is
*low* enough to allow what you need and on the second tab put a check
mark next to "Trust Access to Visual Basic Project"

Bob

I added a COM reference of Excel 2003 object model so I can
drive Excel from my C# .net application.

I've added code in a button click to write on an Excel worksheet.

When I run my application and click on the button,
the application interrops and an error occurs :

"SecurityException was unhandled"
"Cet assembly n'autorise pas les appelants d'un niveau de confiance
partiel."
(sorry for the last one in french, but my IDE is in french) : in
english it
would
sound like :
"This assembly does not authorize the appelants of a partial
reliable
level."

I've tried the exemple found at
:http://support.microsoft.com/default.aspx/kb/302084
but the error occurs again.

Products used :
Microsoft Visual C# .Net 2005 (Microsoft Visual Studio 2005 Pro SP1)
.Net 2.0 Framework
Microsoft Excel 2003 SP2 (Microsoft Office 2003 Pro)

What can I do to make it work ?

Thanks,
Claude
 

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