Re: Problems referencing Excel using C# - urgent!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Trilok Khairnar (trilok_khairnar_at_persistent.co.in)
Date: 05/07/04


Date: Fri, 7 May 2004 16:52:53 +0530

Hello Peter,

I have a similar problem.
I am trying to access MS Excel using automation from a c# class in my
ASP.Net web application. .Net framework version is 1.1
I can access Excel 2000 as 'using Excel' and my project has a reference to
Excel 9.0 library.
I cannot access Excel as "using Excel = Microsoft.Office.Interop.Excel;"

I am running Widows 2000 Pro SP4. Need I be concerned with the Microsoft
PIAs?
Or the PIAs are only for Windows XP?

I get an exception as soon as I instantiate an object of Excel.Application
or Excel.ApplicationClass().
The exception stack trace is as follows:

[COMException (0x80080005): Server execution failed]
   Ypc.DSquare.Common.Pages.Wait.Page_Load(Object sender, EventArgs e) in
D:\DSquare\Phase1\Src\Web\Common\Pages\Wait.aspx.cs:92
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731

 In machine.config. The ASP.Net has attribute username = "SYSTEM" for the
processmodel tag.

Thanks in advance,
Trilok.

""Peter Huang"" <v-phuang@online.microsoft.com> wrote in message
news:6ko9jt$MEHA.308@cpmsftngxa10.phx.gbl...
> Hi Barry,
>
> A primary interop assembly is a unique, vendor-supplied assembly that
> contains type definitions (as metadata) of types implemented with COM.
> There can be only one primary interop assembly, which must be signed with
a
> strong name by the publisher of the COM type library. A single primary
> interop assembly can wrap more than one version of the same type library.
>
> For detailed information please refer to the link below.
> Primary Interop Assemblies
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
> l/cpconlocatingprimaryinteropassemblies.asp
>
>
> Also because the .net runtime will probe for the assembly in the GAC first
> and then the other path. That is to say, if the PIA is installed in the
> GAC, even if we have set the copylocal property to true, and a interop
> assembly will exist in the application's debug directory, but the .net
> runtime will still use the assembly in GAC.
> For detailed information about How the Runtime Locates Assemblies, please
> check the link below.
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
> l/cpconhowruntimelocatesassemblies.asp
>
> As your concern that the Word will not use the Assembly in the GAC, am I
> right?(you may check by check the path of the word assembly as I have said
> in my last post)
>
> I think it may be caused by that the word PIA is not installed properly,
> you may try to re-register the PIA.
> Please perform the installation steps again as described in the Office XP
> PIA Readme will most likely solve the problem. The Readme file is shipped
> with the office XP install package.
>
> You may try my suggestion and let me know the result.
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>



Relevant Pages

  • Re: Automating Excel w/ C# - how to define a cell range using "1,1" format rather than &qu
    ... > Primary Interop Assemblies ... if the PIA is installed in the ... > For detailed information about How the Runtime Locates Assemblies, ... > Please perform the installation steps again as described in the Office XP ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Problems referencing Ms.office.interop classes (library 10.0) using C#
    ... I'll look into the possibility that my installation of the Word ... > Primary Interop Assemblies ... if the PIA is installed in the ... > For detailed information about How the Runtime Locates Assemblies, ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Custom Property Reader/Comparer
    ... be parts, assemblies, or drawings. ... I wrote one of these utilities that works as a VBA project in Excel. ... The limitations are: It doesn't retreive configuration ...
    (comp.cad.solidworks)
  • Re: Documents in differenet directory than Assemblies + template versus document
    ... about changing the location of the document and assemblies: ... When you open an Excel template, it creates a new document based on the ... > I'm finally able to deploy my Excel VSTO beta 2 app to different clients ...
    (microsoft.public.vsnet.vstools.office)
  • Re: Excel Automation
    ... I used the Record Macro function to record inputing names in 2 different ... where you can use Excel or Word as your UI. ... > assemblies, a whole new world of problems opens up, so I don't recommend it. ... PIAs save you all this hassle and more. ...
    (microsoft.public.dotnet.languages.csharp)