V
Vyacheslav Akeyev
Hi all,
My web application is using the library Microsoft.Office.Interop.Word.dll
for MS
Office 2003.
MS Office 2007 was installed onto the server the first, afterwardsMS Office
2003 was
installed , than MS Office 2007 was uninstalled. Than Primary
Interop Assemblies for Office 2003 were installed. When the program
code does the tries to run Microsoft Word 2003 exception with message
"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:
could not be found. (Exception from HRESULT: 0x80030002
(STG_E_FILENOTFOUND))." appeares. The server works under Misrosoft Windows
Server 2003.
Program code:
public TemplateDOC(string templateName)
{
_Application tempw;
try
{
tempw = new Application();
CultureInfo culture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");
word = new Application();//ÚÁÐÕÓËÁÅÍ Word
word.DisplayAlerts = WdAlertLevel.wdAlertsNone;
Thread.CurrentThread.CurrentCulture = culture;
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
tempw.Quit(ref saveChanges, ref missing, ref missing);
Marshal.ReleaseComObject(tempw);
tempw = null;
}
catch(Exception ex)
{
throw new Exception(ex.Message, ex);
}
object templName;
if (templateName == string.Empty)
{
templName = missing;
}
else
{
templName = templateName;
}
try
{
//ÓÏÚÄÁ£Í ÎÏ×ÙÊ ÄÏËÕÍÅÎÔ Ó ÛÁÂÌÏÎÏÍ
word.Documents.Add(ref templName, ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
throw new Exception("Unable to open file: " + templateName, ex);
}
}
Could you help me to solve this problem.
Thanks in advance.
Vyacheslav Akeyev
My web application is using the library Microsoft.Office.Interop.Word.dll
for MS
Office 2003.
MS Office 2007 was installed onto the server the first, afterwardsMS Office
2003 was
installed , than MS Office 2007 was uninstalled. Than Primary
Interop Assemblies for Office 2003 were installed. When the program
code does the tries to run Microsoft Word 2003 exception with message
"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:
could not be found. (Exception from HRESULT: 0x80030002
(STG_E_FILENOTFOUND))." appeares. The server works under Misrosoft Windows
Server 2003.
Program code:
public TemplateDOC(string templateName)
{
_Application tempw;
try
{
tempw = new Application();
CultureInfo culture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-US");
word = new Application();//ÚÁÐÕÓËÁÅÍ Word
word.DisplayAlerts = WdAlertLevel.wdAlertsNone;
Thread.CurrentThread.CurrentCulture = culture;
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
tempw.Quit(ref saveChanges, ref missing, ref missing);
Marshal.ReleaseComObject(tempw);
tempw = null;
}
catch(Exception ex)
{
throw new Exception(ex.Message, ex);
}
object templName;
if (templateName == string.Empty)
{
templName = missing;
}
else
{
templName = templateName;
}
try
{
//ÓÏÚÄÁ£Í ÎÏ×ÙÊ ÄÏËÕÍÅÎÔ Ó ÛÁÂÌÏÎÏÍ
word.Documents.Add(ref templName, ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
throw new Exception("Unable to open file: " + templateName, ex);
}
}
Could you help me to solve this problem.
Thanks in advance.
Vyacheslav Akeyev