com-interop

How do I call a visual basic 6.0 method in c#?

烈酒焚心 提交于 2019-11-29 14:10:56
I would like to call a method which is written in visual basic 6.0 from c# (visual studio 2008). Is it possible? How would I do it? Easiest way to do it is to just compile the VB6 code as an ActiveX DLL. Then you can reference the DLL in your .net project. (Visual studio can reference ActiveX DLLs properly.) Compile your VB6 DLL as activex dll Register it using -> regsvr32 "Full Name And Path of newly compiled vb6 dll".(use Run Dialog or Command Prompt to register) In .net Add refrence - select com tab and search this newly registered dll Now you can use this dll. Note: Whenever you do any

.NET and COM Interoperability : release COM from .NET client

半城伤御伤魂 提交于 2019-11-29 13:41:30
Assume I have a COM object (unmanaged) and .NET Client. Is it necessary to call from the .NET client Marshal.FinalReleaseComObject method in order to release the COM object? No. There is no need to explicitly release a COM object from a .Net client. The COM object will be collected like any other .Net object and will release it's underlying native handle once all references to it are removed. Explicit use of FinalReleaseComObject can actually lead to programming errors. If another component in your code is still referencing the COM object you will be yanking out the native object out from

an unhandled win32 exception occurred in w3wp.exe

让人想犯罪 __ 提交于 2019-11-29 13:13:09
问题 I get the following exception when trying to load an ASP.NET MVC website: Unhandled exception at 0x07070a91 in w3wp.exe: 0xC0000005: Access violation reading location 0x00000000. The Visual Studio Just-In-Time Debugger opens and the only information I can see in the debugger is this: Call stack location: msvbvm60.dll!06c00a91() The website uses some COM objects and everything worked fine until last week. This problem appeared out of the blue. This is the error log from Windows Event Viewer:

How to invoke a method of a private COM interfaces, defined in a base class?

依然范特西╮ 提交于 2019-11-29 12:29:24
How can I invoke a method of a private COM interface, defined in a base class, from a derived class? For example, here is the COM interface, IComInterface (IDL): [ uuid(9AD16CCE-7588-486C-BC56-F3161FF92EF2), oleautomation ] interface IComInterface: IUnknown { HRESULT ComMethod([in] IUnknown* arg); } Here's the C# class BaseClass from OldLibrary assembly, which implements IComInterface like this (note the interface is declared as private): // Assembly "OldLibrary" public static class OldLibrary { [ComImport(), Guid("9AD16CCE-7588-486C-BC56-F3161FF92EF2")] [InterfaceType(ComInterfaceType

Activator.CreateInstance(<guid>) works inside VSIDE but not externally

…衆ロ難τιáo~ 提交于 2019-11-29 10:38:23
I have a bunch of COM objects which all implement the same interface, and need to create one of them as chosen at runtime from a list of options. Since I know the CLSID for each of the implementing COM servers, this should be easy. However, for a certain subset of COM libraries, I can only make this work if I'm running inside of the VS2010 IDE. Here is the entire program I'm using to test with: using System; namespace ComTest { class Program { static void Main(string[] args) { var clsid = "{E8978DA6-047F-4E3D-9C78-CDBE46041603}"; var type = Type.GetTypeFromCLSID(new Guid(clsid)); var obj =

Calling a VB6 DLL function with a complex User Defined Type (UDT) from C#

佐手、 提交于 2019-11-29 10:01:22
I am writing a C# application to call a third party VB6 DLL. I have added reference to the VB6 DLL in the References->COM tab. A particular method in the DLL takes a VB6 UDT (User Defined Type) as a parameter. This UDT is shown as a struct in the auto generated .NET wrapper for COM. The struct has lots of child UDTs / structs as well as members of type VBA.Collection (as shown by .NET metadata). It also has regular data types like string, short, double, int, etc. I am initializing this struct in my C# code as: udtEmployee udtEmpData = default(udtEmployee); I also tried udtEmpData = new

What causes error HRESULT: 0x80010105 (RPC_E_SERVERFAULT)?

梦想的初衷 提交于 2019-11-29 09:29:49
I created a ASP.NET web service that uses a 3rd party payment processing engine to authorize credit card transactions. The web service is hosted on a separate application server and connects to the payment processing server via an ActiveX object ( .ocx extension). Lately, it has been generating a HRESULT: 0x80010105 (RPC_E_SERVERFAULT) exception when I try to establish an connection to the application using an " IsAvaiable " check. Does anyone recommend an good place to start for researching this issue? (I know contacting the vendor would be the first option, but I want to have my "ducks in a

.NET database calls slow when using COM Interop, fast via query analyser

て烟熏妆下的殇ゞ 提交于 2019-11-29 08:54:02
I have an Sql query that looks up a person based on SSN and returns the PersonID (identity column). There is a index on the SSN column in the persons table. I have an old VB 6 application that uses COM/.NET interop to call this query. When it does it runs relatively slow. I set up a trace using SQL Profiler and each call has a duration between 400ms-600ms. If I run the very same query via the query analyser, I get a duration < 30ms. I also have a ASP.NET web site that makes the same exact call and get durations less than 30ms. Normally I would suspect that the COM/.NET interop overhead is

How to tell if Excel Application is in cell-edit mode?

六眼飞鱼酱① 提交于 2019-11-29 08:45:11
I'm writing an Excel Addin using COM Interop from .net. I have a command that pops up a dialog, and from the dialog I do some work like collecting data from the used range of several sheets. The problem is that if a cell is in edit mode, some of the calls that I need to make will throw exceptions. I would like a way of determining before-hand that Excel is in edit mode, so that I can warn the user to finish editing the cell first. Any ideas? There is an Application.Ready property that is supposed to give you this information but in practice it doesn't work reliably. See here for a hackaround.

Why doesn't the office PIA install correctly to the GAC?

微笑、不失礼 提交于 2019-11-29 05:43:16
I am currently working on a c# project, where I need to access Outlook. The development is being done on two different machines, one of which has office installed, and one of which doesn't. I previously asked how to compile my project against the outlook com object, and one of the comments suggested that I compiled against the office primary interop assembly, or PIA. In my downloaded Office 2007 PIA , there is an msi file, that is supposed to install a number of PIAs for the different parts of Office. My problem is that this seemingly doesn't happen. On my office-less machine, after typing