com-interop

Empty string becomes null when passed from Delphi to C# as a function argument

若如初见. 提交于 2020-01-21 09:19:12
问题 I have a native Delphi exe which calls into C# dll via COM interop. Here's the simplest case which demonstrate this issue: Delphi: IClass1 = interface(IDispatch) ['{B29BAF13-E9E4-33D7-9C92-FE28416C662D}'] function Test(const aStr: WideString): WideString; safecall; end; var obj: IClass1; s: string; begin obj := CoClass1.Create as IClass1; s := obj.Test(''); // Returns '[null]' end; C#: [ComVisible(true)] public interface IClass1 { string Test(string aStr); } [ComVisible(true)] public class

IronRuby: Cannot call method on a COM Object with one or more arguments

雨燕双飞 提交于 2020-01-17 03:34:27
问题 When I try and call any method on a COM Object that takes one or more arguments, I get the following error on the last argument: Could not convert argument 0 for call to Open. (ArgumentError) Everything works fine when calling a method that takes no arguments, or getting/setting a property. Here is the code that gives me the error above: def new_com_object(prog_id) System::Activator.CreateInstance(System::Type.GetTypeFromProgID(prog_id)) end xls = new_com_object('Excel.Application') xls

COM Interop with IPC in C#

你离开我真会死。 提交于 2020-01-16 00:26:40
问题 I have a question about IPC with COM Interop objects. I want to create and fill with data COM Interop object in one process (for example Windows Service written in C#). Then I want to get it in another process (console application in C#). I know that COM objects don't serialize and they are unmanaged code. I tried realize solution by .Net Remoting (Windows Service is server, console application is client), but I couldn't get COM Interop object in client (I made .net class inherited from

Need to call a .Net Class library dll from a Classic ASP Page

旧街凉风 提交于 2020-01-15 06:51:27
问题 I need to call a .Net Class Library from a vbscript application I have written a C# class library and created a COM DLL component and a type library file I have successfully registered the dll and tlb on my local computer using C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe "C:\user\Visual Studio 2008\Projects\[Sample]\[Sample]\bin\Debug\[Sample].dll" /tlb "C:\user\Visual Studio 2008\Projects\[Sample]\[Sample]\bin\Debug\[Sample].tlb" The dll and the type library file are registered

ASP.Net Com-InterOp Excel Generation issue when hosting

你说的曾经没有我的故事 提交于 2020-01-13 08:08:15
问题 In my ASP.Net application I'm generating a Excel file using MsExcel Object Libby (Com-InterOp) . The application worked fine in the VS dev. environment. But when I host it in the server I'm getting following error, if I'm no user is logged in to the server through Remote desktop Connection. "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a The server process could not be started because the configured

Outlook Interop Exception

痴心易碎 提交于 2020-01-11 11:26:07
问题 Trying to automate Outlook as Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI"); and getting following exception at second line i.e. GetNamespace Unable to cast COM object of type 'Microsoft.Office.Interop.Outlook.ApplicationClass' to interface type 'Microsoft.Office.Interop.Outlook._Application'. This operation failed because the QueryInterface

Can not add reference a COM in COM client?

谁都会走 提交于 2020-01-10 02:34:30
问题 A COM server is create and I registerd that. When I am trying to add that COM server in a COM Client, I was not able to add, and following error is comming. " A reference to 'COMTest' could not be added The ActiveX type Library 'c\user\~\Debug\COMTest.tlb' was exported from a .NET assembly and can not added as a reference. Add a reference to .NET instead " can anybody tell me What is the mistake. I register the COM in both way, from VS also and also tried with command prompt. 回答1: This is a

Fill in word form field with more than 255 characters

懵懂的女人 提交于 2020-01-07 01:12:13
问题 I am trying to programmaticly fill in a microsoft word form. I am successfully able to do so if the string is under 255 chars with the following code below, however it says the string is too long if i try and use a string over 255 chars... How do I get past this limitation? If I open the word doc in word I can type in more than 255 chars without a problem. Does anyone know how to input more characters via c# code? object fileName = strFileName; object readOnly = false; object isVisible = true

Integrating C# & C++ application using secured COM via referenced C++ .TLB

大城市里の小女人 提交于 2020-01-06 20:24:04
问题 I'm trying to get my C#4.0 (VS2010) app to interact with a C++ app using COM and a referenced type library. All the examples I've seen using third-party libraries mostly include ActiveX controls or dll's where you can simply add a reference and create objects. I'm unable to create any objects directly (I get an error saying to use the interface instead) and I'm unable to find anything that will return the interface. This is a secure COM library for accessing an encrypted database and requires

How do I always get COMException instead of OutOfMemoryException?

十年热恋 提交于 2020-01-06 08:00:11
问题 My C# code consumes a COM object. Sometimes that COM object methods will return E_OUTOFMEMORY but it will get translated into System.OutOfMemoryException instead of System.Runtime.InteropServices.COMException with appropriate ErrorCode . This is a problem for me because it complicates my error handling - I'd prefer to have all error indications that arise from COM object methods being thrown as System.Runtime.InteropServices.COMException only. Is it possible to always have System.Runtime