interop

tlbimp.exe converts HWND to _RemotableHandle

試著忘記壹切 提交于 2019-12-09 04:24:28
Our COM component interface has the next method: HRESULT CreatePluginWindow([in] HWND hParent, [in] RECT* prcView); We are going to use it in .NET application but interop for this interface is looking like this: void CreatePluginWindow(ref interop.alfrontx._RemotableHandle hParent, ref interop.alfrontx.tagRECT prcView) According my investigation there is no way to use this method without unsafe code. I'd not like to change COM interface in order to use other than HWND type for hParent, because it's used in many C++ components. I'd not like to make changes in interop because they are compiled

How to get page number?

杀马特。学长 韩版系。学妹 提交于 2019-12-09 03:38:17
问题 I have this code: Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); object nullobj = System.Reflection.Missing.Value; object file = openFileDialog1.FileName; Microsoft.Office.Interop.Word.Document doc = app.Documents.Open( ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); doc.ActiveWindow.Selection

Does WCF FaultException<T> support interop with a Java web service Fault

扶醉桌前 提交于 2019-12-09 01:47:39
问题 I have written a java axis2 1.4.1 web service and .net 3.5 WCF client and I am trying to catch the wsdl faults thrown. Unlike .net 2.0 the .net 3.5 claims to support wsdl:fault and the service reference wizard does generate all the correct fault classes in the client proxy. But when I try to catch a fault it doesn't seem to correctly serialise so that I can only catch (FaultException ex) and not the type I actually threw using FaultException<T> I had a look inside my reference.cs I can see

How to marshal an array of structs - (.Net/C# => C++)

浪尽此生 提交于 2019-12-09 01:34:52
问题 Disclaimer: Near zero with marshalling concepts.. I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer. What are the right set of attributes I need to decorate my struct definition ? [ComVisible (true)] [StructLayout(LayoutKind.Sequential)] public struct A { public string strA public B b; } [ComVisible (true)] [StructLayout(LayoutKind.Sequential)] public struct B { public int Count; [MarshalAs

Passing vector struct between C++ and C#

一个人想着一个人 提交于 2019-12-09 01:33:28
问题 I have c++ unmanaged code that i want to access from c#. So i followed some tutorials and i build a dll for my project (only one class btw). Now i want to use it from c#, and i'm using p/invoke as follows. my question is: is it possible to marshall my windows point so i can pass it as a vector into my c++ code? i can change all the code (except the qwindows point, but i can make my own point). IS there a solution where i dont have to create a c wrapper? i was following this question: How to

Mono interop: Loading 32bit shared library does not work on my 64bit system

核能气质少年 提交于 2019-12-09 01:05:53
问题 i have a problem running a simple interop example on my system. I built a simple 32-bit shared library called libtest.so (c++) g++ -c -fpic test.cpp -m32 g++ -shared -fpic -o libtest.so test.o -m32 My System: Ubuntu Linux 10.04 x86_64 Mono C# compiler version 2.4.4.0 In addition i have a sample c# program using my shared library: using System; using System.ComponentModel; using System.Runtime.InteropServices; public class Test { [DllImport("libdl.so")] static extern IntPtr dlopen(string

How do I properly return a char * from an Unmanaged DLL to C#?

随声附和 提交于 2019-12-09 01:02:09
问题 Function signature: char * errMessage(int err); My code: [DllImport("api.dll")] internal static extern char[] errMessage(int err); ... char[] message = errMessage(err); This returns an error: Cannot marshal 'return value': Invalid managed/unmanaged type combination. What am I doing wrong? Thanks for any help. 回答1: try this: [DllImport("api.dll")] [return : MarshalAs(UnmanagedType.LPStr)] internal static extern string errMessage(int err); ... string message = errMessage(err); I believe C# is

LinqToExcel: Distinct values in excel column

◇◆丶佛笑我妖孽 提交于 2019-12-08 20:49:35
This might be a very simple thing for you gurus, but I'm not familiar with C#4 and INTEROP. Therefore, I'm stumped. Here's my problem. I have a excel column that has duplicate data and I want to trim it down to only unique values. Here's what the data looks like: ColA ColB 10 Adam 12 Jane 14 Adam 18 Adam 20 Eve So, in the end I just want unique names from ColB: Adam Jane Eve I know that I can do this by getting all those values into a List and then adding the Distinct functionality to it. But I think I'm doing something wrong. Anyway, here's my program: Application XLApp = new Microsoft.Office

Calling NetValidatePasswordPolicy from C# always returns Password Must Change

此生再无相见时 提交于 2019-12-08 17:34:28
问题 We have a mvc application that is using Active Directory to authenticate our users. We are leveraging System.DirectoryServices and using the PricipalContext to authenticate: _principalContext.ValidateCredentials(userName, pass, ContextOptions.SimpleBind); However this method only returns a bool and we want to return better messages or even redirect the user to a password reset screen for instances like: The user is locked out of their account. The users password is expired. The user needs to

C# Marshalling bool

送分小仙女□ 提交于 2019-12-08 17:01:45
问题 Scenario This should be an easy task, but for some reason I can't get it going as intended. I have to marshal a basic C++ struct during a reversed-P/Invoke call (unmanaged calling managed code). The issue only arises when using bool within the struct, so I just trim the C++ side down to: struct Foo { bool b; }; Since .NET marshals booleans as 4-byte fields by default, I marshal the native boolean explicitly as a 1 byte-length field: public struct Foo { [MarshalAs(UnmanagedType.I1)] public