interop

didBeginContact passed PKPhyicsObject

旧巷老猫 提交于 2019-12-04 08:20:51
I have a helper method which extends SKPhysicsContact extension SKPhysicsContact { /// - returns: `[SKPhysicsBody]` containing all the bodies that match `mask` func bodiesMatchingCategory(mask: UInt32) -> [SKPhysicsBody] { let bodies = [bodyA, bodyB] return bodies.filter { ($0.categoryBitMask & mask) != 0 } } } in didBeginContact() I call this method on the passed in contact . func didBeginContact(contact: SKPhysicsContact) { let ballMask: UInt32 = 0x1 << 2 let ball = contact.bodiesMatchingCategory(ballMask) ... I get this error message sometimes (like 1 in 5) which crashes the app: -

how to call a C function from C# with a WCHAR* out parameter?

不羁岁月 提交于 2019-12-04 07:54:40
I'm having a bit of problem with marshaling and I just can't figure it out by myself. I've searched for this topic, but hadn't have any luck yet, so basically I'm trying to call an unmanaged C function from my managed C# application. The signature of the C function looks like this: long MyFunction(WCHAR* upn, long upnSize, WCHAR* guid, long* guidSize); I don't access to the .dll file, I just know that the function is being exposed for usage and I know what the function is supposed to do, but I don't know what happening inside, so the function receives a WCHAR* upn holding a UserPricipalName

tlbexp.exe changes method names' case

℡╲_俬逩灬. 提交于 2019-12-04 07:09:04
I have a rather strange problem. I am exporting an interface from a C# library to COM. I have enabled the 'register with COM' project setting, so it calls tlbexp.exe to make the type libs. We use camel case on our method names and I noticed that the exported type library changes these any method that happens to coincide with a class name to Pascal case... e.g interface IFoo { void randomClass() } class RandomClass { } The exported IFoo in the type lib defines IFoo->RandomClass() instead of IFoo->randomClass() Any ideas on what causes this and how to stop it? Since COM is case-insensitive, both

C# sizeof(enum) alternative? (to workaround resharper false error)?

孤街醉人 提交于 2019-12-04 06:41:08
In C# I've got some "safe" API code related to UAC elevation. It involves getting the size of an enum (as follows) int myEnumSize = sizeof (MyEnum); The code itself is valid, compiles, works correctly etc. But Resharper falsely flags it as a an error ("Cannot use unsafe construct in safe context") within the solution. ( Starting with version 2.0 of C#, applying sizeof to built-in types no longer requires that unsafe mode be used. ) I love Resharper, and I love the solution analysis, but with this code in the solution I have a big red dot in the corner that makes me always think something is

How can I write a generic C function for calling a Win32 function?

那年仲夏 提交于 2019-12-04 06:26:16
To allow access to the Win32 API from a scripting language (written in C), I would like to write a function such as the following: void Call(LPCSTR DllName, LPCSTR FunctionName, LPSTR ReturnValue, USHORT ArgumentCount, LPSTR Arguments[]) which will call, generically, any Win32 API function. (the LPSTR parameters are essentially being used as byte arrays - assume that they have been correctly sized to take the correct data type external to the function. Also I believe that some additional complexity is required to distinguish between pointer and non-pointer arguments but I'm ignoring that for

I want to know what functions are available from a Win32.DLL

拜拜、爱过 提交于 2019-12-04 06:26:04
I have a DLL file that has some helpful functions I want to call in my application. Unfortunately I don't have the documentation for it any longer. Is there any way I can discover what are the functions exported by the DLL and their method signature? Maybe there's a utility that lists the functions and their arguments. Know of any? The windows SDK used to include the dependency walker GUI utility that can be used to explore DLL content: Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all

Java client to WCF service interop with mutual certificate - Cannot resolve KeyInfo for verifying signature

对着背影说爱祢 提交于 2019-12-04 06:25:43
Exception: MessageSecurityException: Cannot resolve KeyInfo for verifying signature: KeyInfo 'SecurityKeyIdentifier I have to set up a WCF service to receive SOAP calls from a Java client that is sending signed content with the following header: <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soap:mustUnderstand="1"> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-2"> <ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10

.NET/C# Interop to Python

萝らか妹 提交于 2019-12-04 05:25:25
My backend is written in .NET/C#, I have a requirement that I need to execute python scripts passing context from the .net side of the house. These are queued up in a background task engine called hangfire running as a windows service. I did a little digging and found IronPython , however, after implementing it failed to support many of the pypi python packages that I need to execute inside my script. Secondly, I looked at Python.Net which is a embedded interpreter that embeds or extends CPython. CPython can run all the scripts/etc that I needed, however, I found that opening/closing the

How to release COM objects in Silverlight 4

谁都会走 提交于 2019-12-04 05:23:48
When using COM Interop with Office (usually Excel), I always carefully ensure I call Marshal.ReleaseComObject on every reference, to avoid the problem where Excel doesn't quit as described in this KB article . How can I ensure Excel quits when I use Interop from an OOB Silverlight application (with AutomationFactory.CreateObject )? Silverlight doesn't have a Marshal.ReleaseComObject method and even calling GC.Collect and GC.WaitForPendingFinalizers doesn't help. Surely Microsoft hasn't added this feature to Silverlight without a mechanism to release COM references? This seems to me to be a

Reflection on COM Interop objects

别来无恙 提交于 2019-12-04 05:11:59
Trying to create a mapper for an Microsoft Office object to POCO's and found this // doesn't work // returns an empty array where o is a RCW on an office object foreach(var pi in o.GetType().GetProperties() ) tgt.SetValue(rc, pi.GetValue(o, null)); so have to resort to this foreach(var field in tgt.GetFields() ){ var pv = o.InvokeMember(field.Name, System.Reflection.BindingFlags.GetProperty, null, o, null); i.SetValue(rc, pv); } which works for now but wondering why the RCW.GetProperties() doesn't work here? The other two answers as of this writing are correct, but they miss an important