com

Signing an F# Assembly (Strong name component)

南楼画角 提交于 2019-12-10 02:43:34
问题 I found this article on CodeProject: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus and thought it would be nice to give it a try, but in F#. So I came up with the following code: open System open System.IO open System.Text open System.Runtime.InteropServices open System.Windows.Forms open SharpShell open SharpShell.Attributes open SharpShell.SharpContextMenu [<ComVisible(true)>] [<COMServerAssociation(AssociationType.ClassOfExtension, ".txt")>] type

Generate diagnostic message for HRESULT codes?

北城余情 提交于 2019-12-10 00:30:54
问题 I'd like to be able to do the equivalent of FormatMessage - generate a text message for debug and even runtime builds that can report some of the common HRESULTs, or even spit out things like what the severity is, what facility it was, and possibly a description of the error code. I found this simple function, but its too simple, and mostly seems to generate "unknown error". But so far I haven't found anything that looks more promising. I can do something like the following: CComPtr

Building .NET COMInterop project without first registering the COM service

做~自己de王妃 提交于 2019-12-09 23:44:48
问题 I am building a C# UI to interact with a COM Service (.exe). The VS2005 COM project outputs a valid typelib (TLB), which is referenced by the C# project. However, the VS2005 C# project insists that the service be registered in order to build the C# project, even though the typelib appears perfectly valid when examined with the OLE Object Viewer. We would rather not register the service on the build server, if possible. Further, debug builds cannot register the COM object as a service, since

System.Runtime.InteropServices.ComTypes.IStream to System.IO.Stream

痴心易碎 提交于 2019-12-09 22:08:52
问题 In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ). The framework has a managed definition of the COM IStream interface: System.Runtime.InteropServices.ComTypes.IStream I need this as System.IO.Stream so that I can easily use .NET classes (like XmlDocument) with the output of these imported functions. But I can't see a less painful way of converting this back and forth to System.IO.Stream

Packaging IDispatch Invoke with Parameters in C# (with DISPPARAMS)

ⅰ亾dé卋堺 提交于 2019-12-09 19:00:44
问题 I'm using Invoke for late binding on a legacy COM objects that supports IDispatch. This seems necessary as .NET's Type.GetMethod Type.InvokeMember do not seem to work on these objects. The following code works fine for getting a property from an object, the caller passes in the property name as a string for getting the property value with late binding. The class takes an object in its constructor and sets up this.idisp (and this.lcid) as an interface pointer to the object (Critiques welcome!)

How to release COM objects in Silverlight 4

纵饮孤独 提交于 2019-12-09 18:08:10
问题 When using COM Interop with Office (usually Excel), I always carefully ensure I call Marshal.ReleaseComObject on every reference, to avoid the problem where Excel doesn't quit as described in this KB article. How can I ensure Excel quits when I use Interop from an OOB Silverlight application (with AutomationFactory.CreateObject )? Silverlight doesn't have a Marshal.ReleaseComObject method and even calling GC.Collect and GC.WaitForPendingFinalizers doesn't help. Surely Microsoft hasn't added

Is there a document on .rgs files syntax?

こ雲淡風輕ζ 提交于 2019-12-09 17:31:47
问题 Resource scripts loaded from .rgs files are used with ATL CComModule::UpdateRegistryFromResource() . It's quite common to see samples of such files on the net but I've never seen a complete description on what constructs are allowed in .rgs files. Is there such a document? 回答1: There's some MSDN documentation, but it appears to be pretty unfocused. The book ATL Internals talks at some length about custom replacements. Other than that, I haven't seen much... 来源: https://stackoverflow.com

Unable to access COM exposed methods in VBA

旧时模样 提交于 2019-12-09 16:21:51
问题 I am trying to access COM exposed methods in VBA. Problem: I am seeing all default methods (like GetHashCode , GetType and ToString ) in VBA but not the ones which are part of the COM interface and specifically written to be COM visible (like getStringValue() below). Set up Details: Visual Studio 2008 Windows 7 x64 Office 2007 .NET 3.5 Interface 'IGetMyString.cs' using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices;

Using Interop.MODI Throws 0x80040154 Exception

倖福魔咒の 提交于 2019-12-09 16:06:24
问题 I am currently trying to implement the Interop.MODI.dll (From Microsoft Office) to use the Image -> Text features it should Provide. But when doing var modi = new MODI.DocumentClass(); I get: "COMException 80040154 with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B}". What have I tried to solve that problem? I registered the DLL using the regasm tool: -Problem still exists I tried setting the BuildPlatform to x86: -Problem still exists I use the Visual Studio 2010 Ultimate with Windows 7

Why is COM (Component Object Model) language-independent?

…衆ロ難τιáo~ 提交于 2019-12-09 12:28:36
问题 I know that COM provides reusability at the binary level across languages and applications. I read that all components built for COM must adhere to a standard memory layout in order to be language-independent. I do not understand what "standard memory layout" means. What makes COM language-independent? 回答1: First, some technical background : C++ compilers usually generate something called a "vtable" for any class with virtual functions. This is basically a table of function pointers. The