Problème d'accès à une dll Microsoft
Bonjour,
Je travaille sur un projet C#/ASP.NET, dans lequel j'ouvre des fichiers Word pour en extraire le contenu. Pour cela j'ai inclus la référence à la DLL "Microsoft.Office.Interop.Word", mais l'accès à cette DLL retourne une erreur.
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
protected string recupereObjetDoc (object filePath) {
private Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = null;
try {
object missing = System.Reflection.Missing.Value;
doc = application.Documents.Open (ref filePath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Microsoft.Office.Interop.Word.Paragraph paraNo2 = doc.Content.Paragraphs[3];
if ((paraNo2.Range.End - paraNo2.Range.Start) > 1) {
string result = paraNo2.Range.Text;
doc.Close (ref missing, ref missing, ref missing);
return result;
}
return null;
} catch (Exception ex) {
}
} |
L'exception suivante est levée sur la ligne doc = application.Documents.Open (.... :
Citation:
Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Voici la seule explication relative à mon problème trouvée sur le net :
http://social.msdn.microsoft.com/For...9-e327af8cf8c0
mais la solution ne fonctionne pas chez moi.
Je souligne qu'en local je n'ai pas l'exception, mais lorsque je fais tourner mon application sur un serveur distant (qui a bien sûr Word installé) j'obtiens l'exception.
Auriez-vous une suggestion ?
Merci d'avance.