com

Application.COMAddIns Subscript out of range

送分小仙女□ 提交于 2019-12-13 16:14:55
问题 Following the sample case below https://msdn.microsoft.com/en-us/library/bb608614.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 Run into a 'Subscript out of range' in Set addIn = Application.COMAddIns("ExcelImportData") New to VSTO and C#. How do I debug this? 回答1: If the add-in subscript is out of Range, it suggests that you've either made a typo in the name of the add-in while creating the VSTO project, or you've failed to open Excel using the debugger (which automatically loads the add

Returning TAutoIntfObject instance from TAutoObject

天大地大妈咪最大 提交于 2019-12-13 16:00:54
问题 I'm creating a COM server to allow automation of my program by third party programs. Given that I need to pass around objects with lots of properties, I'm trying to create methods to create such objects for the clients to use. (The intention for this is to allow client programs to create documents that can be passed back to other functions in the main COM object; these document objects contain a lot of properties with no real funcionality.) Given the following classes: Edit : I'm using

Do I have to call Release() method on CComPtr objects?

女生的网名这么多〃 提交于 2019-12-13 15:15:40
问题 I'm working with SAPI5 API for processing text to speech. If I simplify my code looks like this (I removed error checking to simplify it as much as possible): int main() { CoInitialize(NULL); CComPtr<ISpVoice> spVoice; spVoice.CoCreateInstance(CLSID_SpVoice); ... CoUninitialize(); return 0; } For some weird reason my code crashes if I don't call spVoice.Release(). So the code above crashes, but this code works nicely: int main() { CoInitialize(NULL); CComPtr<ISpVoice> spVoice; spVoice

Is there a Click Handler for Shell Extension

白昼怎懂夜的黑 提交于 2019-12-13 15:15:16
问题 After going through MSDN Shell Extensions I am not quite sure if I can extend the behaviour of Shell Click or Click Event of explorer. Any suggestion or Code Snipet, article or Walk through? 回答1: There is no such possibility. That would make the shell too vulnerable. Imagine all the malware that exploits this functionality. If you want to capture the click event, there is no easy way. You may SetWindowsHookEx and monitor/capture mouse messages for all windows of CabinetWClass and/or

C#: Regasm generating registry entries for every class in my COM DLL?

試著忘記壹切 提交于 2019-12-13 15:13:30
问题 I'm writing a class-library (IE BHO) in C# and currently wrangling with the large volume of what I think is junk output coming from REGASM's generated registry keys. The short version is this: I only want to expose a handful of classes (currently: ONE class) to IE (and the rest of COM). Only one class has the ClassInterfaceAttribute and GUID stuff set, and I can test that the add-on only requires the COM registry keys for this class -- and yet, REGASM generates GUIDs and registry keys for

STA (Single Threaded Apartment) COM Object - Spawn worker threads?

你离开我真会死。 提交于 2019-12-13 15:06:09
问题 Is it a bad thing to spawn worker threads in your STA COM object (ie. COM object creates a thread to perform a task)? I think, the answer is - that depends! For example in my case: The worker threads that I am using will not interfere/access COM or COM Services. Reason why I am asking this is because by STA COM definition STA can only house one thread. Spawning multiple threads kind of goes against this principle unless the worker threads and the work they do NOT interfere/deal with COM/COM

Unable to cast COM object of type '…' to interface type '…' while using an ExeCOMServer

╄→尐↘猪︶ㄣ 提交于 2019-12-13 14:55:32
问题 I'm using this exe com server: https://cfx.svn.codeplex.com/svn/Visual%20Studio%202008/CSExeCOMServer/ExeCOMServer.cs my prog is a com app my com method which take another com object is void Init(AppsScriptRunningContext rc); in this method I try to read out an property and get this error Unable to cast COM object of type 'AppsScriptLib.AppsScriptRunningContextClass' to interface type 'AppsScriptLib.IAppsScriptRunningContext'. This operation failed because the QueryInterface call on the COM

Maximum number of excel processes?

人盡茶涼 提交于 2019-12-13 14:42:59
问题 If I do (for example) for (int i=0;i<22;i++) { var app = new Excel.Application(); } then 22 excel processes are created. However, if I do for (int i=0;i<25;i++) { var app = new Excel.Application(); } It creates 22 excel processes, but then most of them dissapear and only a few are left. Is there a limit of 22 or something? Can this be increased? Thanks! EDIT: with following code it doesn't occur: var apps = new List<Application>(); for (int i=0;i<25;i++) { apps.Add(new Application()); } 回答1:

Consuming COM-object from C# console-project

不问归期 提交于 2019-12-13 14:09:50
问题 I have a problem consuming a COM-class from C#. The COM-class is developed in C++ ATL 32-bit. The COM-class works fine when i use it from VBA, VB6, C++, Javascript and even from MSTest/C# The wierd thing is that when i create an instance from a NUnit-test or from a Console application it fails with the exception: System.InvalidCastException : Unable to cast COM object of type 'PvtsFlashLib.FlashClass' to interface type 'PvtsFlashLib.IFlash4'. This operation failed because the QueryInterface

Displaying contents of VARIANT in PHP

删除回忆录丶 提交于 2019-12-13 13:58:13
问题 Edit: Since my first post I have come up with a minimal working example. In the code that follows, how do I access the contents of $testvar ? The relevant places are shown with <--- comments in the following code. $a = array(1.1,2.2); $b = array(6.6,7.7); $testvar = new VARIANT($a,VT_ARRAY|VT_VARIANT); $testvar[0] = new VARIANT($a,VT_ARRAY|VT_VARIANT); $testvar[1] = new VARIANT($b,VT_ARRAY|VT_VARIANT); print "Count: ".count($testvar)."<br />\n"; print "Variant type: "; print variant_get_type(