marshalling

How do I return a byte array from C++ to C#

≡放荡痞女 提交于 2019-12-23 10:29:07
问题 So I've been struggling with this for a little bit. I'm trying to make my own AES 128 library to use with one of my programs. The library tests out and works in C++ (well for the encrypt function.. I haven't implemented the others) The 'Encrypt' function is like this: NEW CODE void Aes128Class::EncryptBlock(BYTE* outBlock, const BYTE* inBlock, const BYTE* cipherBlock) { BYTE temp[16] = {0x00}; Galois::XorBlock(temp, inBlock); Galois::XorBlock(temp, cipherBlock); BYTE expandedKey[176] = {0x00}

Unable to marshal type as XML element because @XmlRootElement annotation is missing

允我心安 提交于 2019-12-23 10:09:51
问题 I want to marshal object to XML. However, it fails with exception: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: unable to marshal type "FreightOfferDetail" as an element because it is missing an @XmlRootElement annotation] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:331) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal

How to use JAXB to marshall/unmarshall a collection of MyBean

荒凉一梦 提交于 2019-12-23 09:13:53
问题 I have a MyBean annotated @XmlRootElement public class MyBean ... Marshalling/Unmarshalling MyBean w/o problems, e.g. JAXBContext jaxbCtx = JAXBContext.newInstance(MyBean.class); Marshaller m = jaxbCtx.createMarshaller(); m.marshal(myBean, writer); How can I use JAXB to marshall/unmarshall a Collection or List? My attempt results in this error: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.internal.SAXException2: unable to marshal type "java.util.ArrayList" as an

Marshal.PtrToStringUni() vs new String()?

假装没事ソ 提交于 2019-12-23 08:47:10
问题 Suppose i have a pointer of type char* to unicode string, and i know the length: char* _unmanagedStr; int _unmanagedStrLength; and i have 2 ways to convert it to .NET string: Marshal.PtrToStringUni((IntPtr)_unmanagedStr, _unmanagedStrLength); and new string(_unmanagedStr, 0, _unmanagedStrLength); In my tests, both calls gives me exactly the same result, but the new string() is like 1.8x times faster than Marshal.PtrToStringUni() . Why is that performance difference? Is there any another

JAXB marshalling Java to output XML file

不打扰是莪最后的温柔 提交于 2019-12-23 07:29:19
问题 problem is how do i generate XML file output instead of system.out? package jaxbintroduction; import java.io.FileOutputStream; import java.io.OutputStream; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here itemorder.Book quickXML = new itemorder.Book(); quickXML.setAuthor("Sillyme"); quickXML.setDescription("Dummie book"); quickXML.setISBN(123456789); quickXML.setPrice((float)12.6); quickXML

marshal c struct to c#

做~自己de王妃 提交于 2019-12-23 05:46:09
问题 Does any body can marshal this part of c/c++ code in c# please? typedef struct { BYTE bCommandCode; BYTE bParameterCode; struct { DWORD dwSize; LPBYTE lpbBody; } Data; } COMMAND, *LPCOMMAND; thanks a lot 回答1: First off, declare the above struct as a managed struct - something like: [StructLayout(LayoutKind.Sequential)] struct SomeStruct { byte bCommandCode; byte bParameterCode; SomeOtherStruct otherStruct; Data Data; } struct SomeOtherStruct { uint dwSize; byte lpBody; } struct Data { }

How to properly release memory when doing custom marshaling (ICustomMarshaler) from native to managed?

最后都变了- 提交于 2019-12-23 05:16:23
问题 My main app is in C# and I'm now trying to write a DLL (for input-output) that should be portable (in C or C++ for both Windows and Linux) and accessible both from others C++ apps and from my main C# app. Although inside my DLL I use C++ to make my life easier, I use C-style methods for the interface, i.e. I have extern "C" { /* methods */} in my headers. I thought this was better than having a C++/CLI wrapper (hope that was the right choice since I'm already far enough, but I would be glad

Problems with JAXB, Marshal, - unable to marshal type “java.lang.String”

北城余情 提交于 2019-12-23 03:22:37
问题 i have a problem, I generated the classes using a schema xsd with xjc. when I run the marshal operation I get the following error: [com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation] at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal

Method's type signature is not PInvoke compatible

若如初见. 提交于 2019-12-23 03:17:16
问题 I am trying to use a function from a c dll, in a c# application, I am facing this error each time i try to run the application and call the function in question. At first i thought maybe this is because of the wrong signature i am using, but i tried to make it as simple as possible yet no luck.! To cut a long story short: This is my actual source code for c dll : #include <stdio.h> #include <string.h> extern "C" { struct teststruct { char acharacter; int anumber; char* astring; char anarray

TypeScript - passing a class as an argument, and reflection

我只是一个虾纸丫 提交于 2019-12-23 03:00:40
问题 I am writing a generic unmarshaller. It converts graph DB data to generated TypeScript (1.8.7) model classes. The input is JSON. The output should be an instance of a model class. My ultimate goal is to create something like Hibernate OGM, only for Tinkerpop Frames and TypeScript, with REST endpoint in the middle. What's the right way to pass a class as a parameter and reach it's static members? I want to have something like this: SomeModel some = <SomeModel> unmarshaller.fromJSON({/*Object