System.UnauthorizedAccessException: Access is denied.

M

MattC

Hi,

I'm trying to use the Office PIA to access MSGraph.
I've placed Microsoft.Office.Interop.Graph.dll in with my C# code and added
it as a reference to the project.

The code compiles, (although what is will do yet???) but when run I am
presented with an Unauthorized Access Exception.

Do I need to give the ASPNET user account access to create the MSGraph COM
object. If so how, does this require DComCnfg??

Below is my code.

Any help or advice greatly appreciated!

TIA

MattC

using System.Runtime.InteropServices;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

MSGraph.Application g = new MSGraph.GlobalClass().Application;
MSGraph.Chart c = g.Chart();
c.ChartArea.Font.Size = 8;
c.Application.Update();
c.ChartType = MSGraph.XlChartType.xl3DBarClustered;
c.HasTitle = true;
c.ChartTitle.Caption = "This is a Test";
c.ChartTitle.Font.Size = 12;
MSGraph.DataSheet ds = g.Application.DataSheet;
ds.Cells.Clear();
ds.Cells[2, 1] = "Widgets";
ds.Cells[3, 1] = "Gadgets";
ds.Cells[4, 1] = "Gizmos";
ds.Cells[1, 2] = "1999";
ds.Cells[1, 3] = "2000";
int row;
int col;
Random r = new Random();
for(row = 2; row <= 4; row++)
for(col = 2; col <= 3; col++)
ds.Cells[row, col] = r.Next(100000);
g.Application.Update(); //Update the changes
g.Application.Quit(); //and deactivate the chart.
 

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

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top