Can we use with ASP.NET

Aug 6, 2009 at 10:48 AM

Will it be feasible if we begin to use it with ASP.NET? I tried to use it, but i am getting following exception :

" System.Exception: Cannot create ActiveX component."


Aug 6, 2009 at 11:57 AM

Commonly is not good idea using office applications in web applications.

Basically - the MS Office design is good for one-user scenarios with ability to use UI. In the webserver is better way using third party components for reading/writing office documents or use a open format ( *.docx , *.xlsx , etc ... ).

Jan 5, 2010 at 10:51 PM
Edited Jan 5, 2010 at 11:06 PM

I am getting the same error "Cannot create ActiveX component."  I am running the sample code in a console app.

The code runs fine in Windows XP desktop , but does not run in Windows 2003 server.

Does this need excel to be installed on the  machine where the app runs?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSExcel = TcKs.MSOffice.Excel;
using System.IO;

namespace TestMSOfficeWrapper
    class Program
        static void Main(string[] args)
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

                System.Console.WriteLine("Before creating Application obj");
                using (MSExcel.Application app = MSExcel.Application.CreateApplication())
 { System.Console.WriteLine("Before getting path"); string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Console.WriteLine(Path.Combine(path,"fxdprice.xls")); MSExcel.Workbook book = app.Workbooks.Open( Path.Combine(path,"fxdprice.xls")); MSExcel.Worksheet sheet = (MSExcel.Worksheet)book.Worksheets[2]; MSExcel.Range range_A1 = sheet.GetRange("F30"); MSExcel.Range range_B2 = sheet.GetRange("F36"); string message = "In cell 'F30' is '{0}' and in cell 'F36' is '{1}'."; message = string.Format(message, range_A1.Value2, range_B2.Value2); System.Console.WriteLine(message); } TcKs.MSOffice.Common.WrapperHelper.GCCollect(); Console.ReadLine(); } catch (Exception ex) { System.Console.WriteLine(ex.Message); Console.ReadLine(); } } } }


Any inputs/ pointers are greately appreciated.




Mar 27, 2010 at 3:15 AM

I tried using this wrapper in a shared hosting solution with ASP.NET but getting: [SecurityException: That assembly does not allow partially trusted callers.]

I then downloaded the source to recompile on my machine, but the Word project seems to be lacking some of the methods that exists in the compiled dlls. There are fo exampel no CreateApplication() and no Documents.Open with one parameter.

Am I misunderstadning something or havn't you uploaded the latest source code?

Mar 29, 2010 at 8:47 AM

@nick_vanaxel: Yes, the MS Office application is required. This library is only .NET wrapper around COM libraries.

Mar 29, 2010 at 8:49 AM

@jespelind: Please try download older version of sourcecode (related to date of binaries, you were used). However I can't recomend using MS Office automatition on webservers. There are severals problems (lacking instances of MS Office applications) which must be workarounded (sometimes helps only killing the process).