com-interop

Is there any purpose of ComDefaultInterface for a COM Callable Wrapper?

◇◆丶佛笑我妖孽 提交于 2019-12-01 20:36:55
问题 What is the purpose of ComDefaultInterfaceAttribute attribute, if the managed object with ClassInterfaceType.None is marshaled as either IUnknown or IDispatch , anyway? Consider the following C# class AuthenticateHelper , which implements COM IAuthenticate : [ComImport] [Guid("79eac9d0-baf9-11ce-8c82-00aa004ba90b")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAuthenticate { [PreserveSig] int Authenticate( [In, Out] ref IntPtr phwnd, [In, Out, MarshalAs

how to stop macros running when opening a Word document using OLE Interop?

◇◆丶佛笑我妖孽 提交于 2019-12-01 20:00:15
As the title suggests, I have a .Net application which uses interop to open documents in Word. I have set app.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable before opening the document. According to the documentation, thhis "Disables all macros in all files opened programmatically, without showing any security alerts" However, when I attempt to open one specific document I get a dialog box on the screen that says "could not load an object because it is not available on this machine". It's a customer document but I believe it contains a macro

Is there any purpose of ComDefaultInterface for a COM Callable Wrapper?

て烟熏妆下的殇ゞ 提交于 2019-12-01 19:30:38
What is the purpose of ComDefaultInterfaceAttribute attribute, if the managed object with ClassInterfaceType.None is marshaled as either IUnknown or IDispatch , anyway? Consider the following C# class AuthenticateHelper , which implements COM IAuthenticate : [ComImport] [Guid("79eac9d0-baf9-11ce-8c82-00aa004ba90b")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAuthenticate { [PreserveSig] int Authenticate( [In, Out] ref IntPtr phwnd, [In, Out, MarshalAs(UnmanagedType.LPWStr)] ref string pszUsername, [In, Out, MarshalAs(UnmanagedType.LPWStr)] ref string pszPassword);

Disable Context Menu on WebBrowser in WPF [duplicate]

假装没事ソ 提交于 2019-12-01 17:22:13
This question already has an answer here: How to deactivate “right click” on WPF Webbrowser Control? 4 answers I have a WPF App that is going to run on a kiosk, on a PC with a touchscreen. The App runs in fullscreen mode, to hide the OS. On one of my pages I have a WebBrowser control that allows a user to view some web pages (navigation is limited to some pages). Since the computer will be placed in a public spot I mustn't let the user access the operating system. The thing is, the touchscreen allows for a right click on the web browser, and that eventually leads to the task bar appearing...

Late binding run-time error in VB6 when creating an object from a .NET assembly

不羁岁月 提交于 2019-12-01 17:21:42
i have a vb6 project that has a reference to a vb.net com library. the project runs well when i use early binding such as: Dim b as object Set b = new myComLib.testObject when i use late binding such as: Dim b as object Set b = CreateObject("myComLib.testObject") i get the following error: Run-time error '429': ActiveX component can't create object Any ideas? thanks The registry entries for the .NET COM Interop class in this case are:- HKEY_CLASSES_ROOT\myComLib.testObject containing a CLSID value and the CLSID entry itself HKEY_CLASSES_ROOT\CLSID\<<myComLib.testObject\CLSID value>> They are

Late binding run-time error in VB6 when creating an object from a .NET assembly

假装没事ソ 提交于 2019-12-01 16:58:10
问题 i have a vb6 project that has a reference to a vb.net com library. the project runs well when i use early binding such as: Dim b as object Set b = new myComLib.testObject when i use late binding such as: Dim b as object Set b = CreateObject("myComLib.testObject") i get the following error: Run-time error '429': ActiveX component can't create object Any ideas? thanks 回答1: The registry entries for the .NET COM Interop class in this case are:- HKEY_CLASSES_ROOT\myComLib.testObject containing a

What is the Guid attribute that appears above classes in C#?

余生长醉 提交于 2019-12-01 15:02:40
I've picked up some C# code recently and one of the classes has a Guid attribute present above it. I don't understand what this is or what it's used for. Can someone give me a rundown of what it is, or just point me in the direction of some articles that give more information about this? Thanks! It is the COM identifier that represents the class in question. The class is designed for COM interop. You might want to take a look at the ComVisibleAttribute class to learn more about the ways you can make managed classes available to unmanaged code. The [Guid] is the exact equivalent to the .NET

Issue passing .NET object from VB6 to .NET

风流意气都作罢 提交于 2019-12-01 13:28:15
We have a .NET dll "A" that is created by a third party. It exposes classes through a tlb to our VB6 exe application. We also have our own .NET dll "B" that references .NET dll "A". "B" also exposes classes to our VB6 exe application through a tlb. Now, the VB6 application has no problem using classes from either library in the VB6 code until we try to call a function in "B" that has a parameter type from "A". In that case, we get an error 430 or an error saying "unable to cast com object of type 'system.__comobject' to type 'Type.From.Dll.A'" What could be causing this? Is this normal? froque

Exposing indexer like properties to COM

ぐ巨炮叔叔 提交于 2019-12-01 11:10:37
I have in existing COM-interface. I wan't to create a .net assembly that exposes a new interface as COM (with a new GUID), but the structure of the interface needs to be the same. How can i create a .net class (C#) that exposes this interface? [ odl, uuid(1ED4C594-DDD7-402F-90DE-7F85D65560C4), hidden, oleautomation ] interface _IFlashPhase : IUnknown { [propget] HRESULT _stdcall ComponentName( [in] short i, [out, retval] BSTR* pVal); [propput] HRESULT _stdcall ComponentName( [in] short i, [in] BSTR pVal); [propget] HRESULT _stdcall ComponentMolePercent( [in] short i, [out, retval] double* pVal

Empty string becomes null when passed from Delphi to C# as a function argument

五迷三道 提交于 2019-12-01 11:04:57
I have a native Delphi exe which calls into C# dll via COM interop. Here's the simplest case which demonstrate this issue: Delphi: IClass1 = interface(IDispatch) ['{B29BAF13-E9E4-33D7-9C92-FE28416C662D}'] function Test(const aStr: WideString): WideString; safecall; end; var obj: IClass1; s: string; begin obj := CoClass1.Create as IClass1; s := obj.Test(''); // Returns '[null]' end; C#: [ComVisible(true)] public interface IClass1 { string Test(string aStr); } [ComVisible(true)] public class Class1 : IClass1 { public string Test(string aStr) { if (aStr == null) return "[null]"; if (aStr == "")