com-interop

Building a COM interop library for ASP Classic using 4.0 framework and Visual Studio 2010

混江龙づ霸主 提交于 2019-11-26 18:09:51
问题 After going through a number of different articles and not finding anything especially conclusive that takes me step-by-step through the process, I've come seeking help. The Scenario A client of mine is only proficient in development for ASP Classic. They have recently acquired an account for a site originally written in ASP.NET. They are rolling the site into something they can actively maintain, but the site originally included an image handler that took dynamically changing data regarding

Fastest way to interface between live (unsaved) Excel data and C# objects

。_饼干妹妹 提交于 2019-11-26 17:13:46
I want to know what the fastest way is of reading and writing data to and from an open Excel workbook to c# objects. The background is that I want to develop a c# application that is used from Excel and uses data held in excel. The business logic will reside in the c# application but the data will reside in an Excel workbook. The user will be using Excel and will click a button (or do something similar) on the excel workbook to initiate the c# application. The c# application will then read data off the excel workbook, process the data, and then write data back to the excel workbook. There may

How to create a HelloWorld COM Interop in Visual Studio 2012

丶灬走出姿态 提交于 2019-11-26 16:56:16
问题 First off, I am new to COM, and currently quite confused. I've read a lot of documentation on COM on MSDN and the general web, but a lot of it seems outdated and overly complex. Here's what I believe to be necessary to get it to work. It doesn't yet, so I am sure I am missing something, but by giving my recipe, I hope someone can spot the problem: Create a C# console app project. I name it CSharpApp Create a C++ ATL project. I call it ComLib.Interop. Add class (template: ATL Simple Object),

How to correctly marshal VB-Script arrays to and from a COM component written in C#

坚强是说给别人听的谎言 提交于 2019-11-26 16:17:25
问题 I'm building a COM object in C# (.Net 4.0) to be used in an classic asp site. Now I'd like to know what's the proper way to marshal VB-Script arrays (single and multidimensional) back and forth between the component and the asp site? A code sample would be highly appreciated. 回答1: VBScript only likes to handle SAFEARRAY's that contain VARIANTS. And it likes to have these passed arround in VARIANTS on the COM methods or properties. So you need to construct a VARIANT property that contains a

Await and SynchronizationContext in a managed component hosted by an unmanaged app

若如初见. 提交于 2019-11-26 16:08:26
问题 [EDITED] This appears to be a bug in the Framework's implementation of Application.DoEvents, which I've reported here. Restoring a wrong synchronization context on a UI thread may seriously affect component developers like me. The goal of the bounty is to draw more attention to this problem and to reward @MattSmith whose answer helped tracking it down. I'm responsible for a .NET WinForms UserControl -based component exposed as ActiveX to a legacy unmanaged app , via COM interop. The runtime

Type exists in 2 assemblies

橙三吉。 提交于 2019-11-26 15:42:25
问题 I have created two .NET Interop assemblies from two different third-party COM DLLs. Both of the COM DLLs contained a type named COMMONTYPE . Therefore, COMMONTYPE is now exposed through the two Interop assemblies as well. I have a third project that needs to use these two Interop assemblies, and I get the infamous compile time error: The type <ABC> exists in both <ASSEMBLY1.dll> and <ASSEMBLY2.dll> Since the COM DLLs are provided by a third-party vendor, I have no access to the source code,

Handling events from out-of-proc COM server in managed STA application

不打扰是莪最后的温柔 提交于 2019-11-26 14:48:22
问题 Apparently, managed handlers for events, sourced from an unmanaged out-of-process COM server, are called back on a random pool thread, rather than on the main STA thread (as I'd expect). I've discovered this while answering a question on Internet Explorer automation. In the code below, DocumentComplete is fired on a non-UI thread (so "Event thread" is not the same as "Main thread" in the debug output). Thus, I have to use this.Invoke to show a message box. To the best of my knowledge, this

What are alternatives to generic collections for COM Interop?

走远了吗. 提交于 2019-11-26 14:08:58
问题 I am attempting to return a collection of departments from a .NET assembly to be consumed by ASP via COM Interop. Using .NET I would just return a generic collection, e.g. List<Department> , but it seems that generics don't work well with COM Interop. So, what are my options? I would like to both iterate over the list and be able to access an item by index. Should I inherit from List<Department> , implement an IList , IList<Department> or another interface, or is there a better way? Ideally I

Releasing temporary COM objects

僤鯓⒐⒋嵵緔 提交于 2019-11-26 14:08:22
问题 Consider the following C# code using a COM object. MyComObject o = new MyComObject; try { var baz = o.Foo.Bar.Baz; try { // do something with baz } finally { Marshal.ReleaseComObject(baz); } } finally { Marshal.ReleaseComObject(o); } This will release the COM objects o and baz , but not the temporary objects returnd by o.Foo and o.Foo.Bar . This can cause problems, when those objects hold a large amount of unmanaged memory or other resources. An obvious but ugly solution would be, to clutter

Starting and stopping IIS Express programmatically

假装没事ソ 提交于 2019-11-26 09:16:14
问题 I am trying to build a small application in C# which should start/stop an IIS Express worker process. For this purpose I want to use the official \"IIS Express API\" which is documented on MSDN: http://msdn.microsoft.com/en-us/library/gg418415.aspx As far as I understand, the API is based (only) on COM interfaces. To use this COM interfaces I\'ve added a reference to the COM library in VS2010 via Add Reference -> COM -> \"IIS Installed Versions Manager Interface\": So far so good, but what\'s