Welcome to WebmasterWorld Guest from 35.173.47.43

Forum Moderators: ocean10000

Message Too Old, No Replies

Complete Simple Code With Error

Using Microsoft.Office.Interop.Excel

     
4:10 pm on Jun 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 13, 2006
posts:125
votes: 0


Here is the code:

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Microsoft.Office.Interop.Excel" %>
<html>
<head>
<script runat="server">
void Page_Load(Object s, EventArgs e)
{
Excel.Application MSExcel = new Excel.Application();
MSExcel.Quit();
}
</script>
</head>
<body>
<asp:Label ID="lblMsg" runat="server" />
</body>
</html>

Here is the error:

CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Here is what I have tried:

1. Installing XP PIA library on the server.

2. Installing full office and enabling .NET Programmability Support on the server.

3. Installing Visual Studio on the server and trying to install XP PIA through that.

Where is my hair

I'm assuming it has been scattered to the four winds by now because I've pulled it all out trying to figure out what is going on. Maybe the answer is something very simple but I am totally missing it right now. Everything I'm finding online is telling me to install the office PIA but after following all the instructions in three different ways I'm still getting the same error. Any help?

8:11 pm on June 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 13, 2006
posts:125
votes: 0


Update: I modified my web.config file as follows:

<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation>
<assemblies>
<add assembly="Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/>
<add assembly="Microsoft.Office.Interop.Owc11, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/>
</assemblies>
</compilation>
</system.web>
</configuration>

I also imported a new namespace in my source code:

<%@ Import Namespace="Microsoft.Office.Interop.Owc11" %>

Now I'm getting a new error:

Compiler Error Message: CS0246: The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 12: void Page_Load(Object s, EventArgs e)
Line 13: {
Line 14: Excel.Application MSExcel = new Excel.Application();
Line 15: MSExcel.Quit();
Line 16: }

Anyone have ideas from this point on?

8:43 pm on June 24, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 13, 2006
posts:125
votes: 0


Ok I've mostly solved this issue now by modifying this line:

Excel.Application MSExcel = new Excel.Application();

to be like this:

Microsoft.Office.Interop.Excel.Application MSExcel = new Microsoft.Office.Interop.Excel.Application();

Now I'm getting the error:

ASP.NET is not authorized to access the requested resource.

Once I set permissions for Excel correctly my issue should be resolved.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members