com

Determining the COM object blocking finalizer

心不动则不痛 提交于 2019-12-07 03:11:46
问题 We have a .NET background processing application (console app) that executes some arbitrary workloads (basically internal users supply .NET DLLs implementing "Execute" interface). Background processing application then loads the dll via reflection and executes it. One of the supplied DLLs apparently has a COM object in it which is not properly disposed (likely). As the processing time is quite long, AND we have COM objects created on the main thread and not disposed properly, this causes a

How do I load a typelib to parse it in C#?

为君一笑 提交于 2019-12-07 03:10:14
问题 In unmanaged code I can use LoadTypeLib() to obtain an ITypeLib* pointer and use that to look into the typelib to find what interfaces it contains. There is System.Runtime.InteropServices.ComTypes.ITypeLib interface in C# but I can't find an equivalent to LoadTypeLib() function. How do I load a typelib and obtain an ITypeLib reference in C#? 回答1: Copied straight from System.Design.NativeMethods, Reflector is useful: [DllImport("oleaut32.dll", PreserveSig=false)] public static extern ITypeLib

COMException in C# when hooking into event

守給你的承諾、 提交于 2019-12-07 03:02:32
问题 I am receiving a COM Exception when trying to hook into an event on a COM Object. Here is the code I am trying to execute. COMClass a = IComClass as ComClass; a.SomeEvent += new SomeEvent_EventHandler(MethodNameHere); Line two throws an exception of type COMException with the following information: System.Runtime.InteropServices.COMException was caught Message="Exception from HRESULT: 0x80040202" Source="mscorlib" ErrorCode=-2147220990 StackTrace: at System.Runtime.InteropServices.ComTypes

COM Interop registration

。_饼干妹妹 提交于 2019-12-07 02:15:05
问题 I have a .NET assembly which I am exposing to COM. The assembly has two public interfaces and one public class. When I build the assembly I get this warning: (assemblyName.dll) does not contain any types that can be registered for COM Interop. My assembly information includes the following line. [assembly: ComVisible(true)] Most people having this problem on the web, that I have found, fixed it with the above line in their assembly information. This has not helped for me. I also tried adding

Programmatically determine if a COM library (.DLL) is installed

假如想象 提交于 2019-12-07 02:10:32
问题 Is there a programmatic way in C# to determine whether a particular COM DLL has been installed? Or is this a matter of scanning the registry for the classId? 回答1: What I usually did (and would do, if I needed this again) is try to create an object instance of a class you know is in the COM library - either by ProgID or GUID - and checking for failure. 回答2: Try and create it, and handle the error if not. Under Win32 CoCreateInstance will return REGDB_E_CLASSNOTREG if not installed (including,

Communication between applications

十年热恋 提交于 2019-12-07 01:19:47
问题 I have 3 choices to use : sockets, activeX, com , in order to communicate between applications on one computer. Which is faster ? 回答1: As long as this runs on one machine, interprocess communication is fundamentally throttled by the bus bandwidth. A memory-to-memory copy, whether that's done in the TCP/IP stack, the named pipe support code or shared memory. Which makes them all equally efficient. One detail matters though, the amount of data that's transferred and the number of software

What are the alignment limitations of the standard global default operator new?

点点圈 提交于 2019-12-07 01:03:09
问题 I'm working on some older code that uses ATL's CComBSTR type. I'm changing it so that it will compile using Visual C++ Express Edition, which does not come with ATL. I used only a very small subset of CComBSTR , so doing this is fairly simple. However, when allocating the BSTR memory block, I need to fill the first four bytes with a 4 byte length prefix. I'm concerned that if I use a new char[size] expression to allocate the memory for the string, that I will cause alignment faults due to the

Python COM server with VBA late biding + skip win register (no admin rights)

余生长醉 提交于 2019-12-07 00:35:32
I'm trying to import Python code into in VBA. The code below works but requires admin rights . Is there a way to go around the win register need (assume I just don't have admin rights) but keep the 'late biding' behavior (dont want to Tools>>Reference every time I compile something new) class ProofOfConcept(object): def __init__(self): self.output = [] def GetData(self): with open('C:\Users\MyPath\Documents\COMs\SourceData.txt') as FileObj: for line in FileObj: self.output.append(line) return self.output class COMProofOfConcept(object): _reg_clsid_ = "{D25A5B2A-9544-4C07-8077-DB3611BE63E7}"

.NET RTD/COM Excel Interop errors on one user's machine?

允我心安 提交于 2019-12-07 00:19:32
We built a .NET COM/Excel RTD Server (.NET Assembly) which has been in use for many years, on a variety of machines (i.e. we know it works, and our standard method for installing it works). We have a user who installed this RTD component on a different machine, and is having problems getting it to function smoothly. I believe the problem relates to the Interop.Microsoft.Office.Interop.Excel.dll somehow being either incompatible with this machine, or else improperly registered. Here are specific details: Although RTD links are working to some extent, we see this error frequently logged by our

How to find out a COM prog id?

只愿长相守 提交于 2019-12-07 00:13:16
问题 I'd like to access a COM library via late binding. How can I find out its progID? Type oClassType = Type.GetTypeFromProgID("THE MISSING PROGID"); 回答1: The progID is generally going to be of the form Library.Class, you can view what classes a COM library exposes using oleview. The feature you want in oleview is View TypeLib (three little red triangles). The Library name will be at the top and you will want to use the name of the class as seen under CoClasses 来源: https://stackoverflow.com