TeDeSm
asked on
VB.Net Exception Received After Upgrade to Word 2013
I have a project that worked with Word 2010 but after upgrade to Word 2013 gives an exception. I have changed the References to Microsoft Word 15.0 Object Library.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.ComponentModel
Imports Word = Microsoft.Office.Interop.W ord
<snip>
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph
<snip>
Try
oWord = CType(System.Runtime.Inter opServices .Marshal.G etActiveOb ject("Word .Applicati on"), Word.Application)
Catch
oWord = New Word.Application ' EXCEPTION ON THIS LINE
End Try
Exception wording is:
System.Runtime.InteropServ ices.COMEx ception was unhandled
ErrorCode=-2146959355
HResult=-2146959355
Message=Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-0 0000000004 6} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE) ).
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Re motingServ ices.Alloc ateUniniti alizedObje ct(Runtime Type objectType)
at System.Runtime.Remoting.Ac tivation.A ctivationS ervices.Cr eateInstan ce(Runtime Type serverType)
at System.Runtime.Remoting.Ac tivation.A ctivationS ervices.Is CurrentCon textOK(Run timeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.C reateInsta nce(Runtim eType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInterna l& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateI nstanceSlo w(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateI nstanceDef aultCtor(B oolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateIns tance(Type type, Boolean nonPublic)
at System.Activator.CreateIns tance(Type type)
at PurchaseChaser.PurchaseCha ser.SendFa x(String SageAccount, String FaxNumber, String EmailAddress, String DocPreference, Int64 CountryCode, String PreferredPrinterName) in E:\Visual Studio Projects\Projects\Purchase Chaser\Pur chaseChase r\Purchase Chaser.vb: line 746
at PurchaseChaser.PurchaseCha ser.SendFa xStart(Str ing PreferredPrinterName) in E:\Visual Studio Projects\Projects\Purchase Chaser\Pur chaseChase r\Purchase Chaser.vb: line 456
at PurchaseChaser.PurchaseCha ser.btnSta rt_Click(O bject sender, EventArgs e) in E:\Visual Studio Projects\Projects\Purchase Chaser\Pur chaseChase r\Purchase Chaser.vb: line 1110
at System.Windows.Forms.Contr ol.OnClick (EventArgs e)
at System.Windows.Forms.Butto n.OnClick( EventArgs e)
at System.Windows.Forms.Butto n.OnMouseU p(MouseEve ntArgs mevent)
at System.Windows.Forms.Contr ol.WmMouse Up(Message & m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Contr ol.WndProc (Message& m)
at System.Windows.Forms.Butto nBase.WndP roc(Messag e& m)
at System.Windows.Forms.Butto n.WndProc( Message& m)
at System.Windows.Forms.Contr ol.Control NativeWind ow.OnMessa ge(Message & m)
at System.Windows.Forms.Contr ol.Control NativeWind ow.WndProc (Message& m)
at System.Windows.Forms.Nativ eWindow.De buggableCa llback(Int Ptr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Unsaf eNativeMet hods.Dispa tchMessage W(MSG& msg)
at System.Windows.Forms.Appli cation.Com ponentMana ger.System .Windows.F orms.Unsaf eNativeMet hods.IMsoC omponentMa nager.FPus hMessageLo op(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoopInner (Int32 reason, ApplicationContext context)
at System.Windows.Forms.Appli cation.Thr eadContext .RunMessag eLoop(Int3 2 reason, ApplicationContext context)
at System.Windows.Forms.Appli cation.Run (Applicati onContext context)
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.OnRun( )
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.DoAppl icationMod el()
at Microsoft.VisualBasic.Appl icationSer vices.Wind owsFormsAp plicationB ase.Run(St ring[] commandLine)
at PurchaseChaser.My.MyApplic ation.Main (String[] Args) in 17d14f5c-a337-4978-8281-53 493378c107 1.vb:line 81
at System.AppDomain._nExecute Assembly(R untimeAsse mbly assembly, String[] args)
at System.AppDomain.nExecuteA ssembly(Ru ntimeAssem bly assembly, String[] args)
at System.Runtime.Hosting.Man ifestRunne r.Run(Bool ean checkAptModel)
at System.Runtime.Hosting.Man ifestRunne r.ExecuteA sAssembly( )
at System.Runtime.Hosting.App licationAc tivator.Cr eateInstan ce(Activat ionContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.App licationAc tivator.Cr eateInstan ce(Activat ionContext activationContext)
at System.Activator.CreateIns tance(Acti vationCont ext activationContext)
at Microsoft.VisualStudio.Hos tingProces s.HostProc .RunUsersA ssemblyDeb ugInZone()
at System.Threading.ThreadHel per.Thread Start_Cont ext(Object state)
at System.Threading.Execution Context.Ru nInternal( ExecutionC ontext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Execution Context.Ru n(Executio nContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Execution Context.Ru n(Executio nContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHel per.Thread Start()
InnerException:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.ComponentModel
Imports Word = Microsoft.Office.Interop.W
<snip>
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph
<snip>
Try
oWord = CType(System.Runtime.Inter
Catch
oWord = New Word.Application ' EXCEPTION ON THIS LINE
End Try
Exception wording is:
System.Runtime.InteropServ
ErrorCode=-2146959355
HResult=-2146959355
Message=Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-0
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Re
at System.Runtime.Remoting.Ac
at System.Runtime.Remoting.Ac
at System.RuntimeTypeHandle.C
at System.RuntimeType.CreateI
at System.RuntimeType.CreateI
at System.Activator.CreateIns
at System.Activator.CreateIns
at PurchaseChaser.PurchaseCha
at PurchaseChaser.PurchaseCha
at PurchaseChaser.PurchaseCha
at System.Windows.Forms.Contr
at System.Windows.Forms.Butto
at System.Windows.Forms.Butto
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Butto
at System.Windows.Forms.Butto
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Nativ
at System.Windows.Forms.Unsaf
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at System.Windows.Forms.Appli
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at Microsoft.VisualBasic.Appl
at PurchaseChaser.My.MyApplic
at System.AppDomain._nExecute
at System.AppDomain.nExecuteA
at System.Runtime.Hosting.Man
at System.Runtime.Hosting.Man
at System.Runtime.Hosting.App
at System.Runtime.Hosting.App
at System.Activator.CreateIns
at Microsoft.VisualStudio.Hos
at System.Threading.ThreadHel
at System.Threading.Execution
at System.Threading.Execution
at System.Threading.Execution
at System.Threading.ThreadHel
InnerException:
Try this solution
https://support.microsoft.com/en-us/kb/870655
Update the following registry key
HKEY_LOCAL_MACHINE\System\ CurrentCon trolSet\Co ntrol\Sess ion Manager\SubSystems\Windows
To do this, follow these steps:
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate the following registry subkey:
HKEY_LOCAL_MACHINE\System\ CurrentCon trolSet\Co ntrol\Sess ion Manager\SubSystems
By default, the Windows entry in the subkey has a value that is similar to the following (all on one line):
%SystemRoot%\system32\csrs s.exe ObjectDirectory=\Windows SharedSection=1024,3072 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServe rDllInitia lization,3 ServerDll=winsrv:ConServer DllInitial ization,2 ProfileControl=Off MaxRequestThreads=16
Right-click the Windows entry, and then click Modify. The Edit String dialog box appears.
In the Value data box, locate SharedSection, add 512 to SharedSection, and then click OK.
The newly changed Windows entry reads as follows:
%SystemRoot%\system32\csrs s.exe ObjectDirectory=\Windows SharedSection=1024,3072,51 2 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServe rDllInitia lization,3 ServerDll=winsrv:ConServer DllInitial ization,2 ProfileControl=Off MaxRequestThreads=16
https://support.microsoft.com/en-us/kb/870655
Update the following registry key
HKEY_LOCAL_MACHINE\System\
To do this, follow these steps:
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate the following registry subkey:
HKEY_LOCAL_MACHINE\System\
By default, the Windows entry in the subkey has a value that is similar to the following (all on one line):
%SystemRoot%\system32\csrs
Right-click the Windows entry, and then click Modify. The Edit String dialog box appears.
In the Value data box, locate SharedSection, add 512 to SharedSection, and then click OK.
The newly changed Windows entry reads as follows:
%SystemRoot%\system32\csrs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Registry settings left over from a previous version of Microsoft Office caused conflicts within the VB.Net project when creating documents in Microsoft Office 2013. Clean our previous Office registry entries before installing Office 2013.
Open in new window