interop

What can I do to target API in .NET 1.1 from .NET 4.0 (VS2010) project?

南笙酒味 提交于 2019-12-22 13:31:23
问题 I developed programs in C# .NET 4.0 using 3d-party libraries in .NET 4.0 and now I was asked to target a 3d-party program that has API only in .NET 1.1 I overlooked some previous discussions telling that it is impossible: MSDN .NET Framework Multi-Targeting Packs for Visual Studio 2010 SO Can I still target .NET Framework 1.1 in VisualStudio 2010? etc. This is weird that I cannot acsess previous .NET from a .NET (4.0). The article: Working with .NET 1.1 in Visual Studio 2008 and Team Server

What can I do to target API in .NET 1.1 from .NET 4.0 (VS2010) project?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 13:31:02
问题 I developed programs in C# .NET 4.0 using 3d-party libraries in .NET 4.0 and now I was asked to target a 3d-party program that has API only in .NET 1.1 I overlooked some previous discussions telling that it is impossible: MSDN .NET Framework Multi-Targeting Packs for Visual Studio 2010 SO Can I still target .NET Framework 1.1 in VisualStudio 2010? etc. This is weird that I cannot acsess previous .NET from a .NET (4.0). The article: Working with .NET 1.1 in Visual Studio 2008 and Team Server

Marshalling ArgIterator to va_list

那年仲夏 提交于 2019-12-22 13:01:08
问题 So, I got an idea to try to p/invoke C functions that take va_list . I know how to p/invoke classic varargs functions (with __arglist ), and as it seemed to me that va_list works just like an ArgIterator , I thought it might be possible to just pass it to the method: [DllImport("msvcrt.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] public static extern int vswprintf(StringBuilder str, int length, string format, ArgIterator args); public static int vswprintf

Workaround to see if Excel is in cell-edit mode in .NET

老子叫甜甜 提交于 2019-12-22 12:25:14
问题 I have an application written in VB.NET that interacts with Excel via interop. I eventually ran into the known issue of Cell-edit mode (see MSDN and stackoverflow for some background). I have been trying to convert the suggested code to VB.NET but keep getting the following error: Reference required to assembly 'office, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' containing the type 'Microsoft.Office.Core.CommandBars'. Add one to your project. (BC30652) - E:\ ... .vb

Interop'ing between C# and an unmanaged C library

你离开我真会死。 提交于 2019-12-22 10:59:12
问题 I have a small C library in a DLL and I need to call a handful of its methods. It uses pointers and a few structs but is otherwise quite simple. Problem is I'm not terribly knowledgable on .NET's interop with the unmanaged world and my attempts so far keep hitting memory access violation exceptions (presumably due to me not getting the pointers quite right). Could anyone give me some pointers (ooh a pun!) on the best way to approach this? Thank you extern vconfig_t *Pobsopen(Ppoly_t **

Problem creating COM-library only containing enum's

馋奶兔 提交于 2019-12-22 10:46:00
问题 I'm am doing a COM-interop project. Substituting some VB and C++ ATL COM projects with C# and .NET Interop. When i define enumerations in .NET and they are made ComVisible, they get exposed as Typelib.EnumType_EnumValue enstead of just Typelib.EnumValue. The typelib exporter does this to ensure that the value names are unique. But i know that all my enum's are unique, so i don't want the underscores. Also there is a lot of client code that needs alteration if i don't get rid of the

Marshalling arrays of VARIANT using P/Invoke

瘦欲@ 提交于 2019-12-22 10:40:00
问题 Situation: I have a managed (C#, .NET 2.0) application which uses an unmanaged (C++) DLL using P/Invoke. Along with the "simple" methods (POD arguments/return value) there's a requirement to pass a boost::variant value arrays to the code. The reason for it is that these methods pass report data (similar to Excel cells, which can be of any type). C# code accepts them as boxed "object"'s. The previous implementation called for use of SafeArray of COM VARIANT's. However, due to poor coding/not

Convert Word of interop object to byte [] without saving physically

醉酒当歌 提交于 2019-12-22 09:55:47
问题 I have an object created in memory using Microsoft.Office.Interop and Microsoft.Office.Word and with all created, paragraphs, tables and the like. I need this object to generate a content byte [] to feed one field of the same type in a table. The problem that I can not save it in any way physically with a oDoc.Save ("path") in order to use a FileStream and solve my problem. Have tried several solutions and how to use the clipboard, and did not work. Any solution? 回答1: Do you really have to

Passing objects from C# to VBA using COM Interop

半世苍凉 提交于 2019-12-22 09:47:51
问题 Is it possible to pass a custom object (like MyClass[]) from C# to VBA using COM? If not, which is the best solution to get this working? 回答1: I assume you're talking about Excel VBA to C# ... here's a minimal C# class that does it, in a project w default name ClassLibrary1: using System; using System.Runtime.InteropServices; namespace Tester { [ClassInterface(ClassInterfaceType.AutoDual)] public class TestClass { public double D { get; set; } // simple property to get, set a double public

CoCreateInstance exact match in .NET?

天大地大妈咪最大 提交于 2019-12-22 09:39:32
问题 I have in-proc (DLL) COM Server, but I settled in to run as DllSurrogate, for this reason from unmanaged code (Delphi) i have: function TComWrapper.GetServer: IUnknown; begin OleCheck(CoCreateInstance(ServerData^.ClassId, nil, CLSCTX_LOCAL_SERVER, IUnknown, Result)); end; from C# am using now: [DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)] static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr