interop

Service Broker and WCF interoperability

你说的曾经没有我的故事 提交于 2019-12-07 06:29:51
问题 Does SQL Server Service Broker have an ability to communicate with a WCF service? I wanna create a Service Broker service which will send some xml message to WCF service for processing. Of course SQL Server instance and WCF service are deployed on different machines. Is it possible to somehow configure SB service to achieve such goal? 回答1: No. SSB can only communicate with another SSB instance. There is a WCF SSB channel but that is using SSB as a transport channel to a WCF service, the WCF

Marshal a C char[][] array to C#

╄→尐↘猪︶ㄣ 提交于 2019-12-07 06:04:30
问题 I have looked and looked and tried everything I can think of or have found suggested. I'm still not having any luck getting the data I need. I'm using a third party DLL, which I believe is written in C. I need to access the functions from this DLL in C#. For the most part, I have this working, except for one function. The function I'm having problems with has the following header: uint queryNumOfServers(USHORT *NumOfServers, char ServerNames[8][16]); I have the following declared in my C#

How do I get a System.Windows.Form instance from its Win32 handle?

帅比萌擦擦* 提交于 2019-12-07 06:02:50
问题 The following code implements a simple singleton that ensures only 1 instance of my application can be run. However, if another instance is started, I need to be able to grab that instance's command-line arguments, pass them to the initial instance, then terminate the second instance. The issue comes in when I'm attempting to get hold of the first instance of the application. Once I've found the handle of that instance's main form, I pass it to the Control.FromHandle() method, expecting to

C# Com Interop with Windows Media Player Visualisation (With Sample Code)

非 Y 不嫁゛ 提交于 2019-12-07 04:41:01
问题 I am attempting to create a Windows Media Player (WMP) Visualization plugin in C#. I am quite new to exposing C# to COM and may have missed something basic. I have persisted with this for 3 days (about 20 hours) and not got past the single issue I will describe below. For those who don't know, WMP visualizations are the pretty images that show in media player while listening to music. In a nutshell : WMP will call certain methods on my C# COM interface, but not others. I have WMP 11 installed

Get localized friendly names for all winrt/metro apps installed from WPF application

六月ゝ 毕业季﹏ 提交于 2019-12-07 04:38:17
问题 My WPF application needs to list the localized names of all Metro/WinRT applications installed for the user. I created a repo to store a working sample for the code presented: https://github.com/luisrigoni/metro-apps-list 1) Using PackageManager.FindPackagesForUser() method var userSecurityId = WindowsIdentity.GetCurrent().User.Value; var packages = packageManager.FindPackagesForUser(userSecurityId); foreach (var package in packages) Debug.WriteLine(package.Id.Name); } // output: // Microsoft

GAC – Assembly is in the GAC but “Could not load file or assembly”

て烟熏妆下的殇ゞ 提交于 2019-12-07 03:47:58
问题 I have an Interop dll that was generated by Visual Studio for a third-party COM object that I am consuming in a .NET dll. I have registered both my consuming dll and the Interop dll in the GAC. I have to use the GAC because these DLLs are being used by a SharePoint 2010 workflow. When the execution gets to the point where my dll calls the Interop dll the following error was thrown” “Could not load file or assembly” … “The system could not find the file specified” together with the expected

Problem in calling a C++ dll function from C#

不打扰是莪最后的温柔 提交于 2019-12-07 03:47:27
This is my 3rd thread concerning a blowfish problem in C#.Despite the fact I cannot have blowfish implemented in my application, I decided to use it as an external C++ dll. Please note I've tried Blowfish.NET and any other, the problem is that I'm translating code from C++ to C# and the C# code must do exactly the same as the C++ code does. So far: --->C++ DLL source<--- Note the exported functions are in the end of the code C# code(definition) [DllImport("TestDLL.dll", EntryPoint = "Initkey" ,ExactSpelling = true , CallingConvention = CallingConvention.Cdecl)] public static unsafe extern void

Pinning Array of .NET objects

非 Y 不嫁゛ 提交于 2019-12-07 03:14:45
问题 I would like to pin an array of .NET objects (including the objects) in order to allow a native function to do some processing on the objects. As far as I understood, GCHandle.Alloc() does not allow me to do this, because such an array contains references (and the objects might also contain references) which are not blittable. Is there any other option to achieve this? I would be okay with very hack-y suggestions or ones that require Mono. 回答1: Arrays in .NET are represented in contiguous

COMException in C# when hooking into event

守給你的承諾、 提交于 2019-12-07 03:02:32
问题 I am receiving a COM Exception when trying to hook into an event on a COM Object. Here is the code I am trying to execute. COMClass a = IComClass as ComClass; a.SomeEvent += new SomeEvent_EventHandler(MethodNameHere); Line two throws an exception of type COMException with the following information: System.Runtime.InteropServices.COMException was caught Message="Exception from HRESULT: 0x80040202" Source="mscorlib" ErrorCode=-2147220990 StackTrace: at System.Runtime.InteropServices.ComTypes

What is the proper PInvoke signature for a function that takes var args?

橙三吉。 提交于 2019-12-07 01:34:25
问题 There is a native function: int sqlite3_config(int, ...); I would like to PInvoke to this function. Currently, I have this declaration: [DllImport("sqlite3", EntryPoint = "sqlite3_config")] public static extern Result Config (ConfigOption option); (Result and ConfigOption are enums of the form enum Result : int { ... } .) I am actually only interested in the single parameter version of this function and don't need the other args. Is this correct? I am also curious as to how you would declare