Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 9-Nov-12 6:35am
v2
Comments
Maciej Los 9-Nov-12 12:36pm    
Show us your code and mark a line with this error. Debug your program.

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900