com

Why is it possible to create a new instance of a COM interface?

元气小坏坏 提交于 2019-12-19 16:13:12
问题 I don't have very much background regarding COM nor coclasses, so I don't quite understand why I can use the new operator with an interface. From a language/framework-agnostic view, it's confusing why this compiles and runs correctly: using Microsoft.Office.Interop.Excel; public class ExcelProgram { static void Main(string[] args) { Application excel = new Application(); } } Inspecting Application in Visual Studio 2010 shows me: using System.Runtime.InteropServices; namespace Microsoft.Office

Why is it possible to create a new instance of a COM interface?

☆樱花仙子☆ 提交于 2019-12-19 16:13:07
问题 I don't have very much background regarding COM nor coclasses, so I don't quite understand why I can use the new operator with an interface. From a language/framework-agnostic view, it's confusing why this compiles and runs correctly: using Microsoft.Office.Interop.Excel; public class ExcelProgram { static void Main(string[] args) { Application excel = new Application(); } } Inspecting Application in Visual Studio 2010 shows me: using System.Runtime.InteropServices; namespace Microsoft.Office

Can you cast a LPTSTR to a BSTR?

风格不统一 提交于 2019-12-19 15:37:12
问题 Is it legal to cast a LPTSTR directly to a BSTR? Based on my understanding of BSTR, casting a LPTSTR to a BSTR directly will leave you with a corrupted length prefix. The example code explicitly states that a string literal cannot be stored to a BSTR. Can anyone confirm for me that a LPTSTR/LPCTSTR cannot be cast directly to a BSTR without corrupting the length prefix? EDIT: My confusion is from seeing this used in a call to a COM object. It turns out that when compiling the COM dll, a .tli

Can you cast a LPTSTR to a BSTR?

ⅰ亾dé卋堺 提交于 2019-12-19 15:37:07
问题 Is it legal to cast a LPTSTR directly to a BSTR? Based on my understanding of BSTR, casting a LPTSTR to a BSTR directly will leave you with a corrupted length prefix. The example code explicitly states that a string literal cannot be stored to a BSTR. Can anyone confirm for me that a LPTSTR/LPCTSTR cannot be cast directly to a BSTR without corrupting the length prefix? EDIT: My confusion is from seeing this used in a call to a COM object. It turns out that when compiling the COM dll, a .tli

Redemption + Clickonce = :-(

人走茶凉 提交于 2019-12-19 11:50:15
问题 I have a normal windows forms program (Not VSTO) which deploys using click once. The issue is that loads of user are having problems with random errors generally stating (from the IClassFactory failed due to the following error: 80004005). Im deploying Redemption by changing the mode to "Isolated" which appears to work for some users but not others. The users that arn't working can be fixed by manually installing the Redemption DLL. Can anyone explain how to automate the process (I really

Issue passing .NET object from VB6 to .NET

时光总嘲笑我的痴心妄想 提交于 2019-12-19 11:26:59
问题 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

C# component events?

走远了吗. 提交于 2019-12-19 11:19:28
问题 I am attempting to write a C# component which will expose events. The component is to be imported by an unmanaged C++ application. According to a few tutorials I have come up with this code (for the C# side): namespace COMTest { [ComVisible(true), Guid("02271CDF-BDB9-4cfe-B65B-2FA58FF1F64B"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface ITestEvents { void OnTest(); } [ComVisible(true), Guid("87BA4D3A-868E-4233-A324-30035154F8A4")] public interface ITest { void

How do I use a 32 Bit COM object from a 64 bit process?

安稳与你 提交于 2019-12-19 10:57:06
问题 I Use Jacob (JAVA COM Bridge) on a 64 Bit Machine and want to load COM Objects from a 32 bit DLL. How can I do that? 回答1: You will need to host the 32 bit COM object in a 32bit process. So either your entire app will have to run 32bit or youll need to place the COM object in something like COM+ and use cross process calls. 回答2: I solved the problem as follows: Created a small 32 bit out-of-process COM server (.exe) that serves as a factory COM object to create the needed 32 bit objects. So

Java, Jacob and Microsoft Outlook events: Receiving “Can't find event iid” Error

≯℡__Kan透↙ 提交于 2019-12-19 10:29:22
问题 I am writing a Java program that interacts with Microsoft Outlook using the Jacob library (bridges COM and Java). This program creates a new MailItem, displaying its Inspector window to the user. I wish to subscribe to the inspector's Close event to know when the user is finished editing their mail item. To subscribe to the event, I followed the instructions in Jacob's documentation (about 2 ⁄ 3 down the page): The current [event] model is conceptually similar to the Visual Basic WithEvents

IE Com Object, Difference between methods .Navigate and .Navigate2

送分小仙女□ 提交于 2019-12-19 09:06:54
问题 What is the difference between $ie.Navigate("URL") and $ie.Navigate2("URL") ? Get-Member says: Navigate Method void Navigate (string, Variant, Variant, Variant, Variant) Navigate2 Method void Navigate2 (Variant, Variant, Variant, Variant, Variant) Sample Code: $ie = New-Object -ComObject InternetExplorer.Application $ie.visible = $true $ie.Navigate("www.stackoverflow.com") #or $ie.Navigate2("www.stackoverflow.com") 回答1: The difference is in the first argument URL . Here is what MSDN says: