marshalling

How to rewrite or modify XML in android 2.1 version

江枫思渺然 提交于 2019-12-24 03:13:04
问题 I tried to modify XML data using JDOm and transformer concept, this two functions are works in 2.2 version. but whenever i tried to compile in 2.1 i am getting exception. Also i searched this issue in google, they mentioned 2.1 version never support transformer concept. what is the alternative way to modify XML file. String filePath = Environment.getExternalStorageDirectory() + getDir; File file = new File(filePath); if (file.exists()) { Document document = (Document) builder.build(file);

Can you use .net 3.5 Action or Func as Marshalled unmanaged delegates?

こ雲淡風輕ζ 提交于 2019-12-24 03:03:58
问题 After reading Dynamically calling unmanaged dlls in .net I've been trying to modify the code to my liking. I made a class that implements idisposable to wrap load calls in and free them when needed. However I can't seem to figure out the syntax if it is possible to use anonymous delegates with it. var loaded=DynamicLibraryLoader.TryLoad("User32.dll"); var beeper=loaded.GetProcAddress("MessageBeep"); var type=typeof(Action<UInt32>); Action<UInt32> beepAction2=(Action<UInt32>) Marshal

Go: JSON Marshaling an error

为君一笑 提交于 2019-12-24 03:00:13
问题 I'm building a JSON API in Go and I'd like to return error responses as json. Example response: { "error": "Invalid request syntax" } I thought that I could create a wrapper struct that implements the error interface, and then use Go's json marshaler as a clean way to get the json representation of the error: type JsonErr struct { Err error `json:"error"` } func (t JsonErr) Error() string { return t.Err.Error() } This will just marshal a JsonErr as {"error":{}} , is there a way of using the

C++/CLI double pointer typecasting to ref IntPtr for C# access

柔情痞子 提交于 2019-12-24 02:15:06
问题 I am writing a wrapper around C DLL in C++/CLI so that it can be accessed in C# through a managed assembly. Using direct P/Invoke to access C functions via C# is not possible because C DLL raises exceptions which cannot be correctly caught using P/Invoke (exception message is lost when moving across C/C# boundary). So the idea is to create a managed CLI DLL which internally calls C DLL and wraps the exception to Exception class of CLI. So the C DLL function has this declaration. void InitDB

JAXB marshalling object having property of type List<Element> (@XmlAnyElement) doesnt output node value

*爱你&永不变心* 提交于 2019-12-24 00:14:43
问题 Following file TPAExtensionsType.java I have generated from a XSD file. TPAExtensionsType.java /* * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="TPA_Extensions_Type"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <any processContents='skip' maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */

JAX-RS polymorphic POST request: how should I write my JSON?

空扰寡人 提交于 2019-12-24 00:12:24
问题 I'm having a bad time trying to solve this problem with JAX-RS and I believe that it has something to do with the marshalling/unmarshalling process (that I don't know very much about, I assume), and I want to recreate this: The REST endpoint to make a post is /rest/register so my services are defined like this: @ApplicationPath("/rest") public interface RestRegistration { @POST @Path("/register") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) String register

C# Marshal.Copy Intptr to 16 bit managed unsigned integer array

浪尽此生 提交于 2019-12-23 17:09:35
问题 Why does C# Marshal.Copy routine does not have any overload for copying from unmanaged memory pointer to 16 bit managed unsigned integer array? ex: Copy(IntPtr, Byte[], Int32, Int32) Copies data from an unmanaged memory pointer to a managed 8-bit unsigned integer array. Copy(IntPtr, Char[], Int32, Int32) Copies data from an unmanaged memory pointer to a managed character array. Copy(IntPtr, Double[], Int32, Int32) Copies data from an unmanaged memory pointer to a managed double-precision

Indomitable beast: a 2d char array, inside a structure, in the belly of an unmanaged dll

落花浮王杯 提交于 2019-12-23 15:18:57
问题 Having gird my loins and ventured into Legacy Land, having hacked, p-invoked and marshaled every type of wild beast, I now stand before a creature so fierce that, as far as I can tell from an exhausting survey of my brethern-in-arms, not a single code warrior has been left standing. Here are the details. I am attempting to pass a 2d char array (in c#), inside a structure, to a C dll (no source code), which must be able to make changes to the 2d array. The C structure: typedef struct s_beast {

How to marshall c++ char* to C# string using P/INVOKE

假装没事ソ 提交于 2019-12-23 14:54:18
问题 I'm new to C++. I'm calling a C++ function from C# using a PINVOKE and wanting to get a string back as an out parameter. However I just get an empty string back. The int out parameter works fine. Importing: [DllImport ( @"UnamanagedAssembly.dll", CharSet = CharSet.Ansi)] public static extern int Activate(ref int numActivated, StringBuilder eventsActivated); extern "C" __declspec(dllexport) int Activate(int *p_NumActivated, char *p_EventsActivated) {return Activation::GetInstance()->Activate(p

Managed to unmanaged code call causes access violation… sometimes

非 Y 不嫁゛ 提交于 2019-12-23 14:02:04
问题 This code causes the following exception, sometimes : "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" private static TOKEN_GROUPS GetTokenGroups(IntPtr tokenHandle) { var groups = new TOKEN_GROUPS(); uint tokenInfoLength = 0; uint returnLength; var res = GetTokenInformation(tokenHandle, TOKEN_INFORMATION_CLASS.TokenGroups, IntPtr.Zero, tokenInfoLength, out returnLength); if (!res && returnLength > 0) { tokenInfoLength = returnLength; var