Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Win2008-R2 Excel , +
Hi all
Im fairly new to Programming ,Im developing a windows service that gets data from MS SQL database into a Datatable and then I create an excel file and adds the data from the Datatable into the excel file and then sends an email with the excel file as an attachment,I install the service on a Windows Server 2008 and I get this error from the Windows Service
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
 
Please help,Thanks in advance
Posted 9-Nov-12 6:18am
PaulaM490
Edited 9-Nov-12 6:35am
v2
Comments
Maciej Los at 9-Nov-12 12:36pm
   
Show us your code and mark a line with this error. Debug your program.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have built your service directly against the Excel libraries and you don't have excel installed on your server. ...at least not the same version you built your app against.
 
Generally, you don't want to do that anyway. Besides burning an expensive Office license, it will have scaling issues and probably security issues depending on how the service endpoint is deployed. If you want to do this, I suggest you either use the Tools For Office (which provides an interop layer that isolates your app from the Office libraries) or, better yet, use the OpenXML libraries that MS provides to create and manage the Excel file directly... without relying on actual Excel.
 
You didn't mention problems with the mailing part of it either, but I'm guessing you might have used the Outlook libraries since you use the Excel ones. If you run into issues there, I recommend the Redemption library. It makes e-mailing from code a breeze on Windows and bypasses all of the security roadblocks that Outlook puts in the way to sending e-mail from code.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 374
1 Sergey Alexandrovich Kryukov 362
2 Abdul Samad KP 145
3 CPallini 130
4 Richard MacCutchan 110
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,680
2 CPallini 4,850
3 George Jonsson 3,454
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100