Hello
I am new to VSTA and have downloaded the 'COMClient easy integration - using generic COMProxy and VAO' sample and am trying it out.
Wow it takes a lot of complicated setup just to get VSTA and the sample running. I must admit that my knowledge of managed code is rather limited, that is why I am using the sample, and concentrating on the COM part.
I have created a new exe (TestGUI) to replace ComClient and a new ATL
COM Sever (VSTATester) which contains a COM object (HostControlTest) to
replace MSDNComServer.
I can launch the IDE, create a script and run it as a macro. However,
there are some problems with the ref. counting on the ComConnector
which often leads to a crash at shut down!
I have tried to look at Gary's comment (http://www.summsoft.com/files/folders/vsta_samples/entry321.aspx) regarding the StopVSTA, but could unfortunately not make it help. I also tried inserting the 'CoEEShutDownCOM()' and 'CorExitProcess(0)' without much luck.
I do the following:
-Create the pVAO, connector etc. as in the ComClient sample
-Run the macro using pVao->LoadMacros(true);
-Wait for the macro to execute, it uses this.GetHostObject()
-Release the com objects I created
pVao->RegisterHostItem() addref's the ICOMConnector given but the refcount is decreased as the variant containing the ComConnector runs out of scope! This means that I cannot release my ComConnector pointer since this would release the com object causing a crash when the RemoteComObjectAdapter tries to access it.
Further the 'pVao->LoadMacros(true);' call addref's the ComConnector but does not seem to release it. The macro call this->GetHostObject(). Should the macro somehow release the ComConnector?
When I close my application I get an exception somewhere in:
Microsoft.VisualStudio.Tools.Applications.InteropAdapter.dll!Microsoft.VisualStudio.Tools.Applications.ComObjectAdapter.FreeNativeResources()
This is if I debug the 'VAO' project. If I debug my test client it is an unhandled exception. It happend after leaving WinMain of my application.
I assume I am doing something wrong but have now spent many hours debugging and trying various ideas and can still not solve the problem.
Could someone please help? Anyone seen similar problems?
Kind regards,
Kim