Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Automation Excel 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claude - 27 Feb 2008 14:50 GMT
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
Claude - 27 Feb 2008 15:07 GMT
Sorry, the exemple found at :
http://support.microsoft.com/default.aspx/kb/302084
does work fine.

It's only in my project that it doesn't work.

What can I do ?

Thanks,
Claude

> I added a COM reference of Excel 2003 object model so I can
> drive Excel from my C# .net application.
[quoted text clipped - 24 lines]
> Thanks,
> Claude
RvGrah - 27 Feb 2008 17:53 GMT
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.
[quoted text clipped - 23 lines]
> Thanks,
> Claude
Claude - 27 Feb 2008 18:30 GMT
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?
[quoted text clipped - 32 lines]
> > Thanks,
> > Claude
Alvin Bruney [ASP.NET MVP] - 28 Feb 2008 02:57 GMT
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

Signature

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 :
>
[quoted text clipped - 55 lines]
>> > Thanks,
>> > Claude
Claude - 28 Feb 2008 14:21 GMT
I tried "caspol -s off", but the error still occur.

Doh !
Claude

> 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
[quoted text clipped - 62 lines]
> >> > Thanks,
> >> > Claude
Alvin Bruney [ASP.NET MVP] - 29 Feb 2008 02:41 GMT
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.

Signature

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 tried "caspol -s off", but the error still occur.
>
[quoted text clipped - 74 lines]
>> >> > Thanks,
>> >> > Claude
Claude - 29 Feb 2008 13:46 GMT
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

> 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
[quoted text clipped - 83 lines]
> >> >> > Thanks,
> >> >> > Claude

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.