Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLAS...

mercoledì 23 marzo 2011 - 01.17
Tag Elenco Tags  C#  |  .NET 3.5  |  Windows Server 2008

Gemini Profilo | Expert

Ciao a tutti
sto utilizzando questa procedura per recuperare il numero di pagine di un documento word:

public int nPagesDOC(string FileName)
{
int num = 0;
object fileName = FileName;
object readOnly = false;
object isVisible = true;
object objDNS = Word.WdSaveOptions.wdDoNotSaveChanges;
try
{
Word.ApplicationClass WordApp = new Word.ApplicationClass();

// give any file name of your choice.


// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;

// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog

Word.Document aDoc = WordApp.Documents.Open(ref fileName,
ref missing, ref readOnly, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref isVisible,
ref missing, ref missing, ref missing, ref missing);
Word.WdStatistic stat = Word.WdStatistic.wdStatisticPages;
num = aDoc.ComputeStatistics(stat, ref missing);
WordApp.Quit(ref objDNS, ref missing, ref missing);
aDoc = null;
WordApp = null;
GC.Collect();
}
catch (Exception ex)
{
return -1;
}

return num;
}

utilizzo 3 dll:
Interop.Microsoft.Office.Core.dll
Interop.VBIDE.dll
Interop.Word.dll

In locale va tutto bene, ma su un server a 64 bit ricevo questo errore:
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Ho capito che è una questione di versione della dll, ma non so come risolvere questo problema.
Grazie mille
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5