com

When do I need to call ReleaseComObject?

走远了吗. 提交于 2019-12-20 10:44:30
问题 In a Microsoft Office AddIn we are passed COM objects in events. To take a specific case, when Word opens a document we are called and passed a Document object. So when do we need to call Marshal.ReleaseComObject()? If we access the Document object do we need to call release on it? Or can we assume Word has already accessed it and will clean it up? If we access Document.Name that gives us a string. As a string is not a COM object we do not need to clean that up - correct? But if we access any

Cross-platform alternative to COM

旧巷老猫 提交于 2019-12-20 10:43:47
问题 I've been enamoured with component based programming (be it with COM, another system, or just using the paradigm in plain C++). It requires a bit of getting used to, if one is usually used to the "traditional" OOP model, but it's definetely worth it. It's made my code more maintainable and easier to extend. The project I'm currently working on is using the paradigm, but no set system. However, I'd really like to find some sort of system I could use with the following requirements. Switching

COM in the non-Windows world?

半城伤御伤魂 提交于 2019-12-20 10:32:42
问题 Hope this question isn't going to be too vague. Reading through the COM spec and Don Box's Essential COM book, there is plenty of talk of the "problems that COM solves" - and they all sound important, relevant and current. So how are the problems that COM addresses dealt with on other systems (linux, unix, OSX, android)? I'm thinking of things like: binary compatibility across compilers and compiler versions binary component reuse compiling an application such that it has run-time

COM outbound call results in “An outgoing call cannot be made since the application is dispatching an input-synchronous call.”

守給你的承諾、 提交于 2019-12-20 10:24:03
问题 I have a COM server (C++/STA (MFC based app)) and a COM client (C#/MTA). The COM server must live in an STA, since it's an MFC app (I have no choice in this matter). The client issues a call to the server, and the server issues a callback to the client. That's where the error happens ( RPC_E_CANTCALLOUT_ININPUTSYNCCALL ). I'm guessing if the server had been an MTA, this problem would never have arised, but sadly, the documentation for MFC explicitly denies initializing the apartment as an MTA

WindowInteropHelper.Handle — do I need to release it?

情到浓时终转凉″ 提交于 2019-12-20 07:28:48
问题 In WPF I'm getting IntPtr handle using this code: IntPtr mainWindowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle When I finish using this handle, do I need to release it in anyway (e.g. using Marshal.FreeHGlobal() method) ? EDIT: I was thinking about Marshal.FreeHGlobal(), not Marshal.Release(), sorry! 回答1: This is not in any way related to COM, Marshal.Release() does not apply. You simply get a copy of the native window handle, it does not have to be released. You

How can I programmatically control the Microphone and Microphone Boost settings in Win7 from C#?

橙三吉。 提交于 2019-12-20 07:28:05
问题 Windows 7 has some new audio settings which I haven't been able to control from my C# application. Specifically, within the Input (microphone) properties, there is a Levels Tab containing Microphone and Microphone Boost sliders, and a Microphone mute toggle / checkbox. I need to programatically ensure that the Microphone is not muted--but have not found the necessary APIs to either read or set the values. 回答1: I was unable to find an API that provided control over these specific volume levels

Retrieve output parameters from an AutoCAD API method in python

回眸只為那壹抹淺笑 提交于 2019-12-20 07:16:22
问题 I'm trying to retrieve 2 output Arrays from an XRecord in AutoCAD 2016 using python 2.7, with comtypes imported, the first array is an array of integers (DXF Group Codes) and the second array is an array of variants (the values of XRecord). The opposite way of what this question seeks to The method of interest is GetXRecordData , which (according to AutoCAD's documentation) if successful returns None , and only accepts 2 output arguments . when I try to retrieve it with code like DxfGrCd = []

COM object excel interop clean up

 ̄綄美尐妖づ 提交于 2019-12-20 06:35:29
问题 Lets say that I have one component which is doing something with Workbook object and somewhere in the middle of that method body I have call to some method of another class. For example: public class MainComponent { public void MyMainMethod() { OtherComponent otherComponent = new OtherComponent(); Workbook document; // some work with workbook object // working with document and worksheet objects. otherComponent.MethodCall(document); // some work with workbook object and it's worksheets.

in .NET, How do I set STAThread when I'm running a form in an additional thread?

我的梦境 提交于 2019-12-20 06:32:21
问题 I'm running a form in a second thread. If I do Ctrl-C to copy text on the clipboard, I get an Exception, "Current thread must be set to a single thread apartment (STA) before OLE calls can be made. (Using the clipboard involves OLE apparently). Putting the [STAThread] with my thread proc, which is the entry point of my second thread does NOT work. What will work? [STAThread] private void MyFormThreadproc(object o) { form = new MyForm(); Application.Run(form); } 回答1: When you create the thread

Add managed DLL dependencied to unmanaged C++ project

烈酒焚心 提交于 2019-12-20 06:31:12
问题 I have project with managed DLL A.dll which depends on managed B.dll and C.dll. I expose A.DLL to unmanaged C++ project D via COM interface. Everything is okay... But A.DLL can't find D.dll and C.dll and raises appropriate exception. I tried putting them in the same folder but it does not work. How and where should I reference those dependencies? In C++ I would just build A.dll with static linking but .NET does not have this option. Update: putting library in the same directory as .exe file