com

Can't instantiate COM object from ASP.NET MVC app

隐身守侯 提交于 2019-12-13 00:24:33
问题 As the title says, I want to instantiate a COM object from an ASP.NET MVC app like this: dynamic obj = Activator.CreateInstance(Type.GetTypeFromProgID(progID)); but it throws the following ComException: Retrieving the COM class factory for component with CLSID {16542E4F-4594-4B97-922D-BE9C478F93BB} failed due to the following error: 800aea5f Exception from HRESULT: 0x800AEA5F. The same code works from a Winforms app with the following build configuration: Platform: x86 and Platform target:

MainThread blocks when executing a task that interacts with COM

跟風遠走 提交于 2019-12-13 00:07:27
问题 I want to execute some long lasting tasks in a C# gui application (Windows Forms based). I first tried to execute these in parallel with Task.Factory.StartNew() . The tasks involve COM interaction. When I execute the task (which should have been executed in parallel) the main/gui thread shows the busy cursor and does not respond. The object through which the COM calls are made was created in the main thread which uses the single threaded apartment. In these posts: Blocking method of an STA

Out-of-process COM singletons

跟風遠走 提交于 2019-12-13 00:06:35
问题 I am dealing with a single-threaded library (not thread safe) that I want to wrap in a COM out-of-process object to get around its thread non-safety. I need a behavior where each new COM object is instantiated in its own process - some form of out-of-process singleton. It's been a while since I've been dealing with hardcore COM so I am not sure how to approach this or whether this is at all possible without some trickery. 回答1: Call CoRegisterClassObject() with the REGCLS argument set to

Replace native C++ COM .dll with .NET COM .dll

╄→尐↘猪︶ㄣ 提交于 2019-12-13 00:05:20
问题 Our customer has old Win32 clients that use a native C++ COM registered .dll that we provide. We want to replace the native .dll with a .NET version. So we've built the .NET dll and COM registered it. We have native C++ test clients that are able to handle the swap from the old .dll to the new, but... it seems we need to recompile them for it to work. Is there some logical reason why we need to recompile the test client, or are we doing something wrong? We cannot require our customer to

How to use IMalloc::Free?

随声附和 提交于 2019-12-13 00:05:10
问题 I'm using ICommandText::GetCommandText method. According to the MSDN documentation (http://msdn.microsoft.com/en-us/library/ms709825(v=VS.85).aspx) I need to use IMalloc::Free to release the memory allocated for LPOLESTR *ppwszCommand output parameter. How do I use this interface to do that? 回答1: Just pass it to CoTaskMemFree, it's wrapping the same default OLE allocator CoGetMalloc is exposing. CoTaskMemAlloc/Free are convenient shortcuts to IMalloc interface of the default OLE allocator so

How to work with the MSAdminBase COM object in .NET?

♀尐吖头ヾ 提交于 2019-12-12 22:40:31
问题 This object is implemented in %windir%\system32\ADMWPROX.DLL - see HKEY_CLASSES_ROOT\CLSID\{70B51430-B6CA-11D0-B9B9-00A0C922E750} It is perfectly usable from C code, but I wish to replace it with a .NET code and what a bummer - ADMWPROX.DLL does not appear as a valid type library to tlbimp: z:\Work>tlbimp c:\Windows\system32\admwprox.dll Microsoft (R) .NET Framework Type Library to Assembly Converter 4.0.30319.1 Copyright (C) Microsoft Corporation. All rights reserved. TlbImp : error TI1002 :

C++ calling C# COM interop error: HRESULT 0x80131509

不问归期 提交于 2019-12-12 22:33:02
问题 I create a C# COM interop for c++ to invoke. I have registered the dll and tlb file by regasm. everything goes well till one day i changed code of C# part (i didn't change the definition of interface, just implementation changed). one interface in COM returns an error 0x80131509. the strange thing is, it is only happened in some computers (my develop PC is works well so i can't debug this problem). I'm not really clear on how the C# COM worked with C++, after i registered them, i just know

C# COM Class - DISP_E_UNKNOWNNAME

僤鯓⒐⒋嵵緔 提交于 2019-12-12 21:46:45
问题 I have declared a COM visible class in C#. The code is as follows: [ComVisible(true)] public class AComVisibleClass : TheParentClass { public bool SomeFunc(string id) { return true; } } This class is instantiated by a factory class, also COM accessible. But if I try to access in a VB script file, a DISP_E_UNKNOWNNAME exception is thrown. This is a new class on a pre-existent library we have here at work. All other classes are accessible through COM. The whole library is compiled into a single

How do I create interface methods using .tlb types in VS C++?

北城余情 提交于 2019-12-12 21:17:35
问题 Background: The .TLB file contains interfaces written in language 'X'. I don't have .h, .idl, .tlh, or any other header files - just the .TLB file. Language 'X' does not export compatible .h, .idl, etc. I use the VS wizard to add an ATL simple object to my ATL project. I want to add a method to the interface of my simple ATL object that uses one of the .TLB defined types for a parameter. // Something like the following in the .idl file: interface ISomeInterface : IUnknown { HRESULT SomeMethod

An invalid or unaligned stack was encountered during an unwind operation

谁都会走 提交于 2019-12-12 20:18:50
问题 I have a 64bit program that works with VirtualBox COM interface and implements a frontend for the virtual machine. Recently I started getting weird An invalid or unaligned stack was encountered during an unwind operation exceptions and I wanted to at least understand the causes of this. As I understand the stack needs to be 16byte aligned so, I presume unaligned stack pointer likely to cause this. But the thing is, since all my program does is implement a couple of COM interfaces using the