com-interop

Registering my .net assembly for COM interoperability doesn't expose my methods.

Ok, I'm going crazy. I've been trying to make a simple .net assembly visible to use as a COM object but it's not working. I've been trying a lot of different aproaches but none of them work. So far the closest i've got is the one with the least amount of attributes, interfaces, manually registering etc. I have a vbscript as a test which...

Can't instantiate COM component in C# - error 80070002

I'm attempting to instantiate a Windows Media Player COM object on my machine: Guid mediaPlayerClassId = new Guid("47ac3c2f-7033-4d47-ae81-9c94e566c4cc"); Type mediaPlayerType = Type.GetTypeFromCLSID(mediaPlayerClassId); Activator.CreateInstance(mediaPlayerType); // <-- this line throws When executing that last line, I get the followi...

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154.

I developed a Windows service using C#.NET to generate PDF report. To generate PDF file I am using a third party dll. The application is running in my Windows XP platform. When I deployed the service in Windows Server 2008 64 bit version, I got this error: Retrieving the COM class factory for component with CLSID {46521B1F-0A5B-...

writing long text in excel workbook using interop throws error ?

I am writing long text (1K to 2K characters long, plain xml data) into a cell in excel workbook. The below statement throws COM error Exception from HRESULT: 0x800A03EC range.set_Value(Type.Missing, data); If I copy paste the same xml manually into excel it just works fine ,but the same does not work progamatically. If I strip the tex...

Exposing C# via COM for C++ Client

Hi, we're considering exposing some C# types to C++ clients via COM. What problems can we expect to hit over the life of the project? E.g. how will versioning be managed? On versioning, it would seem from reading this that we should decorate our types to be exposed with [ClassInterface(ClassInterfaceType.None)] and use an explicit int...

C++ calling C# options

Hi We have native Win32 C++ code and a set of C# assemblies which we wish to call from the C++ code. I summaries our optios as: Use COM. The C# code would need to be decorated with additional attributes (GUID, COMVisible). The C# assemblies would need to be registered regasm and would then be available to the native C++ code via CO...

Marshaling complex data types between .NET and COM

I have spent the last day or so writing a simple control library in VB.NET to be used in an existing vb6 project. I have most things working; my controls show up in the vb6 toolbox, events work, etc. My current problem is trying to deal with passing complex objects between vb6 and .NET. For example, the Font property of a .NET TextB...

How Can I Create My C# Com Class From JavaScript Using ActiveXObject

I wrote C# class to COM but I could not use it from JavaScript. Example [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [ComSourceInterfaces(typeof(ICommandsEvents))] [ProgId("Scripting.Commands")] public class Commands : ICommands { public Commands() { } public int CreateChannel(string channelName) { ...

Exception handling: how granular would you go when it comes to argument validation?

I'm coding a simple little class with a single method send an email. My goal is to implement it in a legacy Visual Basic 6 project, exposing it as a COM object via the COM Interop facility. There's a detail I'm finding difficult to resolve, that being how granular should I be at validating parameters. On that light, a thing I'm really n...

How to import a tlb and a namespace in c++ at runtime when some condition meets ?

Hi Generally we import a tlb file at the starting of the program like #include < stdio.h > #import " sql.tlb " But i need to import a tlb file when certain condition meets in the middle of the program how can i do this. to load dll there is LoadLibrary() but to load tlb can i use LoadLibrary(). Since tlb is generated by using .dl...

SSIS with COM Interop fails when run as a scheduled job

I have an SSIS Package that utilizes a COM Interop (Interop.RFCOMAPILib.dll) around RightFax's COM API (rfcomapi.dll). The Interop assembly has been GAC'd so that we can use it within the SSIS package The package runs just fine on my local machine. But it also works just fine on the server if it is manually started (meaning all of the ...

Hosting a .net assembly for COM interop with long lifetime?

I have a component (an assembly built in .net) that i need to access on (almost) every request to two different websites. One website is written in classic asp and the other one in asp.net mvc. At the moment i reference the assembly in the asp.net solution and call it like i would any .net assembly. On the classic asp website, i call it...

Force .NET interop to use local COM DLL

Is it possible to force an interop assembly to reference a local copy of its associated COM DLL? Here's the scenario: I have a .NET app that references an interop assembly (Interop.OTAClient.dll), which is the interop for a COM DLL (OTAClient.dll, which is the automation API for HP Quality Center). I'm not very knowledgable on COM, but...

Why is there interface / class (IFoo, FooClass) pattern in Office Interop API?

In the Microsoft.Office.Interop.Visio library each entity (for e.g Shape), is described as a class (ShapeClass) and an interface, Shape. So for each element you have: interface Shape { ... } class ShapeClass : Shape { ... } interface Page { ... } class PageClass : Page { ... } ... Why is it designed like this? ...

using classes inside a COM exe from .Net

I have a .exe file I've been given which has COM classes inside it -- these are from C++, not .net ComVisible types I'd like to use those classes inside my .net project, but I can't add a reference to the exe; when I try I get DIALOG BOX: --------------------------- Microsoft Visual Studio --------------------------- A reference to ...

Invoke a javascript function with VB.net through COM Interop

I have a VB.net class registered for COM interop which I'm instantiating within an HTML page using the following code: <script type="text/javascript"> var MyClass = new ActiveXObject("Namespace.TestClass"); </script> I can call methods on it just fine, but suppose I want to set a javascript function as a property, like so: MyClass.Te...

How to debug vs 2008 c# express dll which is called by a vb6/vba app?

Hi guys, i have a c# dll which is written to act as a wrapper to grab data from a data source and pass it to a vba/powerpoint ppa application. i don't have much experience with vba which is why i'm simulating this using vb6 which i know a tiny bit more about. i'm having enough problem as of now trying to understand the syntax and what...

How To Expose a DIctionary<> to COM Interop

I have an Interface that is defined something along these lines: Interface foo { int someProperty {get; set;} Dictionary<string, object> Items; } The concrete class that implements this interface needs to be registered for COM Interop. Everything compiles and the assemblies seem to register OK, but then when trying to create t...

Marshalling CodeElements to an IntPtr in C#

I am writing a Visual Studio add in and need to marshall a managed CodeElements object to it's unmananged form. I just need the pointer in memory, as I can cast it and treat it like a CodeElement on the unmanaged side. [DllImport("CodeMethodsToString.dll")] private static extern BSTR* CodeMethodsToString(void* functionObject); p...

How to determine if an event is complete using a 3rd Party API - C#?

I am currently working with a third party ActiveX control where I need to detect when an event I called from the API has completed. Looking at the ActiveX control in VS 2008 Object browser, I call public virtual bool MyMethod() and there is an event public virtual event IActiveXObject_MyMethodEventHandler SettleComplete. There is als...