com

Dangers of C# MTA thread creating STA COM object

核能气质少年 提交于 2019-12-12 08:05:31
问题 I'm currently looking at a problem we are having in a .Net Framework 2.0 windows service (C#) that has X number of MTA threads running that access COM components. Each thread initializes it's own instance of the com component object. The com component object does not have any UI elements. It's simply business logic that communicates with a sql server database and a C# dll with a com interface that in turn does socket communication and access to the same sql server database. Through my

.tlh generated on 2 machines is different

扶醉桌前 提交于 2019-12-12 08:03:54
问题 I have a .NET dll which has some interfaces\classes which are exposed to com. during the build procedure a .tlb file is generated and this tlb is referenced by some c++ code. As a result the compiler generates a .tlh file for the tlb. When I run the build locally one of the properties in one of the interfaces ends up with a corresponding method in the tlh which does not have the same name. The property in the .net code is called PropertyA end up being called get_propertyA, while PropertyB

CreateObject equivalent for C# 4, dynamic keyword, and late binding?

与世无争的帅哥 提交于 2019-12-12 07:48:15
问题 How do I create a dynamic COM/OLE/ActiveX object in C# 4.0 from a program identifier or ProgID (such as "Word.Application") without referencing a library? In C# 3.5 I'd have to write something like Type comObjectType = Type.GetTypeFromProgID(progId, true); Activator.CreateInstance(comObjectType); Is there an easier way to do it in C# 4.0 so I can assign it to a variable of type dynamic (using the dynamic keyword)? 回答1: What's wrong with dynamic myTypeInstance = Activator.CreateInstance(Type

Marshalling BSTRs from C++ to C# with COM interop

末鹿安然 提交于 2019-12-12 07:26:51
问题 I have an out-of-process COM server written in C++, which is called by some C# client code. A method on one of the server's interfaces returns a large BSTR to the client, and I suspect that this is causing a memory leak. The code works, but I am looking for help with marshalling-out BSTRs. Simplifying a bit, the IDL for the server method is HRESULT ProcessRequest([in] BSTR request, [out] BSTR* pResponse); and the implementation looks like: HRESULT MyClass::ProcessRequest(BSTR request, BSTR*

Creating Com Error 80004005

大兔子大兔子 提交于 2019-12-12 06:14:52
问题 Im trying to run FoxPro in Windows 2012, I have registered the dll using regsvr32 When i try to run the app using the dll, i got this Error: Creating an instance of the COM component with CLSID {F6C4F46E-58A4-4774-802F-1CF9E64376B0} from the IClassFactory failed due to the following error: 80004005. Trace: at Lib.FoxProWrapper..ctor(String ODBC, String Acct, String Pswd) at App.Processor..ctor(String SrvType, String ServiceName) at App.App.startApp() 回答1: I assume here you are talking about a

Media Foundation set video capture frame rate using PROPVARIANT structure

旧街凉风 提交于 2019-12-12 05:49:04
问题 I'm writing a media foundation application where I need to set the capture frame rate for a video device. The function I'm writing is something like: bool SetRequestedFrameRate(const size_t requestedFramesPerSecond); where I pass a user-defined integer as the frame rate parameter. I'm following the code snippet on https://msdn.microsoft.com/en-us/library/windows/desktop/ff485859(v=vs.85).aspx : PROPVARIANT var; if (SUCCEEDED(pType->GetItem(MF_MT_FRAME_RATE_RANGE_MAX, &var))) { hr = pType-

How to attach to COM event in Javascript

心不动则不痛 提交于 2019-12-12 05:39:48
问题 I have followed this example to create a COM event to be used in javascript. However, I am not a fan of the final attach code? <script for="myComComponent" event="MyFirstEvent(args)" language="javascript"> function myComComponent::MyFirstEvent(args) { alert('event'); } </script> What I would like is to be able to do something more like //in the onload myComComponent.MyFirstEvent = myJavascriptHandler; //function setup function myJavascript(args){ alert('event'); } This works in our older C++

Visual Studio Setup Project failing to add keys to registry

烂漫一生 提交于 2019-12-12 05:38:11
问题 I'm creating a setup pacakage in Visual Studio 2008 to register a COM component and one of the actions is to add a few keys to the registry. The odd thing about it is when I run the installer it creates the key hierarchy correctly but the last key in the hierarchy it creates has the wrong GUID... whereas its right in the installer... has anyone run into this or have any suggestions on what is going wrong? Thanks 回答1: I had the same (or a similar?) problem, my solution is here: How to register

IShellBrowser::BrowseObject isn't called

我是研究僧i 提交于 2019-12-12 05:35:40
问题 I'm trying to implement explorer-like frame in my application. This must work under WinXP too. I've implemented IShellBrowser in my window-class + i've implemented IUnknown interface. My class atributs: IShellViewPtr m_shView; HWND m_wndHolder; CListViewCtrl view; Here is the code of WM_CREATE handler m_hWndClient = view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); // view isn't null after it CMessageLoop* pLoop = _Module

How to register a dll into GAC with Installshield

拜拜、爱过 提交于 2019-12-12 05:35:08
问题 I have installshield 2016 premier and I have a .Net dll that uses a com dll. My application is a plugin so the main exe (its not my exe), is looking mydll in windows even myplugin is in program files. Manually when I use "gacutil.exe -i mydll.dll" it works. Then the dll is not need to be in windows folder. So I tried also regasm but it did not work. So i have to register mydll into gac somehow. The target machine has not gacutil.exe so i cannot call basically from command. I looked at how