com

How do I invoke the MIDL compiler to generate a .TLB file (type library) from an .IDL file?

邮差的信 提交于 2019-12-01 05:15:20
问题 I am struggling with something seemingly super-simple: I'd like to use the MIDL compiler to generate a type library ( .tlb file) from a .idl file. However, I just can't get MIDL to generate a .tlb file. This is my Foo.idl : import "unknwn.idl"; [object, uuid(400075B9-4BD6-45A5-B8B7-9DA0CF7B9B13)] interface IFoo : IUnknown { HRESULT DoFoo([in] int arg, [out, retval] int *result); } This is how I invoke the MIDL compiler: midl Foo.idl /tlb Foo.tlb Which writes the following output to the

Is it ok to (ab)use CoClassAttribute to provide a default implementation for an interface?

こ雲淡風輕ζ 提交于 2019-12-01 05:03:23
问题 I recently discovered that it's possible to "new up" an interface in C# by decorating the interface with the CoClassAttribute to specify a default implementation. [ComImport, Guid("579A4F68-4E51-479A-A7AA-A4DDC4031F3F"), CoClass(typeof(FooImpl))] public interface IFoo { void Bar(); } public class FooImpl : IFoo { public void Bar() { } } ... // Constructs a FooImpl IFoo foo = new IFoo(); I'm aware that this feature exists primarily to support COM-interop, but I was wondering if this would be a

Property/Method Descriptions for COM Libraries

放肆的年华 提交于 2019-12-01 04:58:30
问题 If you create a COMClass, I've noticed that the values in the XML Summary tag do not show in the object browser of VB6/VBA when you reference the resulting tlb file. Is there a way to have these values show up? 回答1: No, 12 years of IntelliSense evolution prevents this from working. The XML documentation comments generates an .xml file that IntelliSense can pick up. In VB6/A, documentation is present in the type library with the helpstring attribute. For example: [ odl, uuid(2334D2B1-713E-11CF

Is there a way for registration free activation of EXE COM components

纵然是瞬间 提交于 2019-12-01 04:56:41
问题 Is there a way to activate a COM component which is an EXE COM application and also it's dependent COM dlls? I want to activate this COM component from .NET application(VS 2005/VS 2008). The path of call is C# application --> invoking out-of-proc exe(this is through COM) and then this out-of-proc invokes few COM dlls 回答1: Reg-free COM does not work for out of process components. ActiveX EXE and ActiveX Document project types cannot be used with Reg-Free COM, as discussed in the sidebar.

Passing string array from VB6 to C#.net

♀尐吖头ヾ 提交于 2019-12-01 04:41:53
How to pass a VB6 string array [Assume, s =Array("a", "b", "c", "d")] to C#.Net through COM Interop? I tried to implement passing C# string array to VB and VB string array to C# as below C#->VB working fine but other way (VB=>C#) giving a compile error called "Function or interface marked as restricted, or the function uses an automation type not supported in visual basic" . My code below C# public interface ITest { string[] GetArray(); void SetArray(string[] arrayVal ); } public class Test : ITest { string[] ITest.GetArray() { //Working fine string[] stringArray = { "red ", "yellow", "blue" }

Why won't my Setup Project Perform my Custom Registration Process

无人久伴 提交于 2019-12-01 04:33:13
I am trying to write an Setup Project/Installer for a class library driver that I wrote in C# using Visual Studio 2008. The driver project has a section of code that looks like this... [ComRegisterFunction] public static void RegisterASCOM(Type t) { Trace.WriteLine("Registration Started."); DoRegistration(true); } In the driver project Properties -> "Assembly Information" I have set checked the box that says Make COM-Visible = true. I added a Setup Project to the solution in VS, added the output dll from the driver project so that it installs on the target machine and set the Register property

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

别等时光非礼了梦想. 提交于 2019-12-01 04:25:37
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* pResponse) { USES_CONVERSION; char* pszRequest = OLE2A(request); char* pszResponse = BuildResponse

COM Exception 80040154 When creating an Excel Application

十年热恋 提交于 2019-12-01 04:03:18
问题 I'm trying to run my application on a server which does not and will not have Office installed on it. using EXCEL = Microsoft.Office.Interop.Excel; ... EXCEL.Application app = new EXCEL.Application();//Exception thrown here The code is working fine on my own system, but on the server it gives the following exception: Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {...} failed due to the following error: 80040154

is DISPID_VALUE reliable for invokes on IDispatchs from scripts?

不羁岁月 提交于 2019-12-01 03:58:16
问题 Continuing from this question, i am confused whether DISPID_VALUE on IDispatch::Invoke() for script functions and properties (JavaScript in my case) can be considered standard and reliable for invoking the actual function that is represented by the IDispatch ? If yes, is that mentioned anywhere in MSDN? Please note that the question is about if that behaviour can be expected, not what some interfaces i can't know in advance might look like. A simple use case would be: // usage in JavaScript

C++: Convert wchar_t* to BSTR?

别说谁变了你拦得住时间么 提交于 2019-12-01 03:55:14
问题 I'm trying to convert a wchar_t * to BSTR . #include <iostream> #include <atlstr.h> using namespace std; int main() { wchar_t* pwsz = L"foo"; BSTR bstr(pwsz); cout << SysStringLen(bstr) << endl; getchar(); } This prints 0 , which is less than what I'd hoped. What is the correct way to do this conversion? 回答1: You need to use SysAllocString (and then SysFreeString). BSTR bstr = SysAllocString(pwsz); // ... SysFreeString(bstr); A BSTR is a managed string with the characters of the string