interop

C# property exposed to VBA (COM) : Run-time error '424': Object required

一个人想着一个人 提交于 2019-12-01 11:14:38
This C# code is in a .NET 4.5 ComVisible assembly: C# Code [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("22341123-9264-12AB-C1A4-B4F112014C31")] public interface IComExposed { double[] DoubleArray { get; set; } object[] ObjectArray { get; set; } object PlainObject { get; set; } double ScalarDouble { get; set; } } [ClassInterface(ClassInterfaceType.None)] [Guid("E4F27EA4-1932-2186-1234-111CF2722C42")] [ProgId("ComExposed")] public class ComExposed : IComExposed { public double[] DoubleArray { get; set; } public object[] ObjectArray { get; set; } public object PlainObject { get; set;

What are my options for C++ DLL to call a C# DLL?

柔情痞子 提交于 2019-12-01 11:10:27
I have a C++ DLL that needs to call a function (pass a value, return a value) in a C# class library. Is my only option to give the C# DLL a COM interface and call it from C++ with IDispatch? Is this the best method? Couple of options available for you here Use a mixed mode C++/CLI assembly as a bridge between the C++ and C# DLL Use the a COM bridge by exposing several of the key C# types as COM objects. This can then be accessed via the C++ code by normal COM semantics This project Creates dll exports for static methods in classes. You could then call a C# static method from unmanaged code.

C# - Excel Number Formatting Issue with International settings

瘦欲@ 提交于 2019-12-01 11:01:50
I am trying to write to an Excel 2003 spreadsheet using c# 3.5. However I am unable to get this to function correctly across different country settings. The country settings are either English or German. These two settings have different decimal and thousands settings. Everything works fine unless a user has changed the decimal and thousands separators in the International settings of the Options screen. Can anybody help as I feel I can no longer see the wood for the trees and am missing something obvious. Summary: Data retrieved from an access database. Read by c# application and written to

Need of ClassInterfaceType.None?

孤街浪徒 提交于 2019-12-01 10:54:22
Didn't quite get the following from MSDN : ClassInterfaceType.None Indicates that no class interface is generated for the class. If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. This is the recommended setting for ClassInterfaceAttribute . Using ClassInterfaceType.None is the only way to expose functionality through interfaces implemented explicitly by the class. Is [ComVisible(true)] a must for COM visibility? See this blog post for the expanation of the first problem. The point is that unless you specify

Raising events in a class library exposed to COM

半腔热情 提交于 2019-12-01 10:38:02
问题 I'm trying to write a wrapper to a service, which will be used by an existing VB6 project. I've got most of the basic framework working, except for one important aspect: I can reference the wrapper in a VB6 project and subs/function calls etc. work as expected, but events do not. The events are visible in the VB6 app, but they never fire. VB.NET Code: Public Event Action_Response(ByVal Status as String) Public Function TestEvent() RaiseEvent Action_Response("Test Done") Return "Done" End

Getting Object Functionality out of C++ code in C#

◇◆丶佛笑我妖孽 提交于 2019-12-01 10:33:11
I have have a function in wrote in C++ that calls some functions in a old lib. This function creates some memory makes the calls and destroys the memory. To optimize this I would create an object that would keep the memory allocated until the object was destroyed. However I'm going to be calling this function from C# and don't believe I can export a Class, just functions or variables. My idea is instead this; Think of the DLL as a class and the use local vars inside the scope of the dll to point to memory. Then have a function to create the memory, call the worker functions and another to

Unable to add a DLL Reference to VS 2008

梦想的初衷 提交于 2019-12-01 09:56:36
问题 I wonder if someone can help me. I'm trying to add a reference to the LAME MP3 encoder in my VB.Net (3.5) App. The DLL I'm using (lame_enc.dll v3.98.2) was downloaded from here: http://rarewares.org/mp3-lame-bundle.php When I try to add the DLL reference to my project, I get an error: "A reference to C:\\Lame_Enc.dll could not be added. Please make sure this file is accessible and that it is a valid assembly or COM component" I would just assume this was a corrupt download/similar but... The

Need signature after SAML token in client request

假装没事ソ 提交于 2019-12-01 09:31:05
I have a serialized SOAP request message with a SAML token holder-of-key that works against a vendor service. I want to create a demonstration program in C# to produce a similar request. To do this, I want to write a client that creates its own SAML token. I've got a SAML2 token created successfully from a self signed cert and I am able to associate it to the request using the ChannelFactoryOperations.CreateChannelWithIssuedToken approach (.Net 4.0). Everything is working great but I can't figure out the C# required to place the signature after the assertion and use the SAML token as the

adapt wrapper class for two dimensional case

你离开我真会死。 提交于 2019-12-01 09:23:16
This question is an extension of this question . I would like to adapt the wrapper for the two dimensional case. This is my first attempt: public class EmxArrayRealTWrapper : IDisposable { private readonly emxArray_real_T _value; private GCHandle _dataHandle; private GCHandle _sizeHandle; public emxArray_real_T Value { get { return _value; } } public EmxArrayRealTWrapper(double[,] data) { _dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); _value.data = _dataHandle.AddrOfPinnedObject(); _sizeHandle = GCHandle.Alloc(new int[] { data.GetLength(0), data.GetLength(1) }, GCHandleType.Pinned);

Need of ClassInterfaceType.None?

你离开我真会死。 提交于 2019-12-01 09:18:04
问题 Didn't quite get the following from MSDN: ClassInterfaceType.None Indicates that no class interface is generated for the class. If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. This is the recommended setting for ClassInterfaceAttribute . Using ClassInterfaceType.None is the only way to expose functionality through interfaces implemented explicitly by the class. Is [ComVisible(true)] a must for COM visibility? 回答1: See