com-interop

ActiveX Control is running in separate window other than IE

ⅰ亾dé卋堺 提交于 2019-12-11 02:41:16
问题 I have developed an ActiveX Control in C#.NET. I created a class library with a default interface. Given GUID , ProgId and made it COM visible , interoperable. Registered. Created a cab file , then embedded it in HTML page using object tag by specifying it's classid and codebase. Loaded it using JavaScript Method. It is working. But problem is that it runs as a separate window other than Internet explorer. I want it to be loaded inside IE that is as a part of IE window. How to do it? --

Can on marshal a string[] to a safearray variant?

北城以北 提交于 2019-12-11 02:39:41
问题 When I marshal my function returning a string[] as UnmanagedType.Struct with SafeArraySubType = VarEnum.VT_ARRAY as in namespace StackOverflow { [ComVisible(true)] [Guid("4BDC43D4-8FD7-4F58-BEE5-E57C3C144C1B")] public class Array { [return: MarshalAs(UnmanagedType.Struct, SafeArraySubType = VarEnum.VT_ARRAY)] public string[] StringArray() { return new string[] { "foo", "bar" }; } } } I was expecting to get a variant (UnmanagedType Enumeration) Struct A VARIANT, which is used to marshal

How to Consume COM Server (ATL, DLL Surrogate) in .NET C# WinService?

岁酱吖の 提交于 2019-12-11 02:16:43
问题 I have a DLL Com Server, actually used only by one old Delphi exe-application. COM Server is written many years ago (not by me) in C++ ATL. It implements callbacks (event - is it the same?) - using outgoing interface IConnectionPointImpl . Class Factory is singleton (marked with DECLARE_CLASSFACTORY_SINGLETON ) Now it is required that this COM Server have to be shared between more than one clients: both Delphi and C# (.NET 2.0, VS2008). I put it as DllSurrogate and now I can use it from

How can I pass a collection of objects from VB6 to .NET?

家住魔仙堡 提交于 2019-12-11 02:04:53
问题 I need to pass a collection of key/value pairs of strings from VB6 to .NET. In VB6 code they exist in a native collection. But I am not sure what I can reference in my .NET project to be able to accept a parameter of type Collection in one of my methods. I tried adding a reference to Visual Basic for Applications but got back "A reference to 'Visual Basic For Applications' could not be added." Am I going about it the wrong way? 回答1: You could use something like this in c#: [Guid("fb5e929a

how to put IDispatch* in managed code

↘锁芯ラ 提交于 2019-12-11 01:59:03
问题 I've been considering trying to write a COM object using C# that implements a OPOS Service Object. I've done it in C++ using Automation and MFC and it wasn't too difficult. So I'm stuck on one of the methods trying to convert it over. I'll exclude the other methods in the interface since they are straight forward (or so I hope). [id(6), helpstring("method OpenService")] LONG OpenService(BSTR lpclDevClass, BSTR lpclDevName, IDispatch* lpDispatch); My C# code looks something like this so far,

Alternative for .NET's System.Convert within VBA

会有一股神秘感。 提交于 2019-12-11 01:32:47
问题 I'm writing a VBA function in Microsoft Access to Encrypt / Decrypt text data using RSA keys. The following works currently: CreateObject("System.Security.Cryptography.RSACryptoServiceProvider") CreateObject("System.Text.UTF8Encoding") but this is not working: CreateObject("System.Convert") I did some research and came across this stackoverflow question: Can I call a static method of a C# class from VBA via COM? So as it turns out, System.Convert is a static class so therefore it is

How do I pass an Array (By Reference, in VB6) to a C\C++ *.dll subroutine?

烂漫一生 提交于 2019-12-10 19:50:41
问题 I need to pass an empty Array of Variants to a DLL written in C (and available on all Windows versions), and the C code (which I have no control over and cannot edit) will populate the Empty Array of Variants with its some return values. Bascially, when I try this - the ByRef Array is always empty when it should contain the results of the function/sub call (if I do the exact same thing in .NET, it works). I'm thinking I need to do a custom declaration so VB knows how to call the C function,

Returning S_FALSE from a C# COM dll

霸气de小男生 提交于 2019-12-10 17:45:15
问题 I have a method defined in IDL as follows : interface IMyFunc : IDispatch { [id(1), helpstring("method GetNextFunction")] HRESULT GetNextFunction( [in,out] long* lPos, [out, retval] BSTR* bstrName); } Using C++ I always implemented this as follows : STDMETHODIMP CMyFunc::GetNextFunction(long *nID, long *lPos, BSTR *bstrName) { if ( function to return ) { // setup return values; return S_OK; } else { // just exit return S_FALSE; } } Now I am implementing this in C# and have used tlbimp on the

Trying to open a file dialog using the new IFileDialog and IFileOpenDialog interfaces in C# with minimal code [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-10 16:45:13
问题 This question already has answers here : When defining a Windows API interface in C#, do I have to define all members? Can I only define the methods I'm going to use? (2 answers) Closed 3 years ago . I'm trying to display a standard open file dialog that can select folders, using the IFileOpenDialog interface in C#, Visual Studio 2010. I'm trying to use the minimal code, so I've only defined the methods I need in the interfaces: using System; using System.Runtime.CompilerServices; using

Is the exception message raised by a C# COMponent passed through interop to C++?

谁说胖子不能爱 提交于 2019-12-10 15:57:17
问题 If I implement a COM interface in a C# class, which will be called from a C++ module, then in case of a failure the C# code should throw an exception; this will be marshalled to a HRESULT failure code by the interop layer. But will any message text (or other information) passed to the Exception constructor also be available to the calling C++ code? If so, how can it be obtained i.e. which API methods? e.g. if in my C# code I do throw new ArgumentException("The email address is invalid") I