I am marshalling (serializing) JAXB beans to output stream. How can I add DOCTYPE declaration and xml processing instructions to ouput?
I am doing currently marshalling like this:
JAXBContext jaxbContext = JAXBContext.newInstance("com.example.package");
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Mar...
i have a struct with dynamic length:
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct PktAck
{
public Int32 code;
[MarshalAs(UnmanagedType.LPStr)]
public string text;
}
when i'm converting bytes[] to struct by this code:
GCHandle handle = GCHandle.Alloc(bytes_array, GCHandleType.Pinned);
result_str...
What's the best way to do this....?
I have some Native C++ code that uses a lot of Win32 calls together with byte buffers (allocated using HeapAlloc). I'd like to extend the code and make a C# GUI...and maybe later use a basic Win32 GUI (for use where there is no .Net and limited MFC support).
(A) I could just re-write the code in C# a...
I've always thought that the concept of Marshalling had a bit of a funny name.
My mental conception of the process would always involve an ol' wildwest gunslinging marshall who would coerce objects into serialized form at gunpoint.
I just found out the real reason Marshalling is called what it's called and chuckled.
(edit) Ok - t...
I put together an XSD and used JAXB to generate classes out of it.
Here are my XSDs-
myDoc.xsd :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.mydoc.org"
targetNamespace="http://www.mydoc.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mtp="http://www.mytypes.com" elementFormDefault="qu...
I am packing bytes into a struct, and some of them correspond to a Unicode string. The following works fine for an ASCII string:
[StructLayout(LayoutKind.Sequential)]
private struct PacketBytes
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string MyString;
}
I assumed that I could do
[StructLayout(LayoutKind....
I have the following C struct from the source code of a server, and many similar:
// preprocessing magic: 1-byte alignment
typedef struct AUTH_LOGON_CHALLENGE_C
{
// 4 byte header
uint8 cmd;
uint8 error;
uint16 size;
// 30 bytes
uint8 gamename[4];
uint8 version1;
uint8 version2;
...
I'm trying to access some Ghostscript functions like so:
[DllImport(@"C:\Program Files\GPLGS\gsdll32.dll", EntryPoint = "gsapi_revision")]
public static extern int Foo(gsapi_revision_t x, int len);
public struct gsapi_revision_t
{
[MarshalAs(UnmanagedType.LPTStr)]
string product;
[MarshalAs(UnmanagedType.LPTStr)]
strin...
Hi,
I have to call a C++ DLL from my C# program.
I'm trying to do it using PInvoke - everything works fine in VS2005\ 2008, but after migration to VS 2010, I get this exception:
PInvokeStackImbalance was detected
Message: A call to PInvoke function
'sampleFunc' has unbalanced the stack.
This is likely because the managed
PI...
Hi,
I don't know how to marshall this structure in Mono.
typedef struct rib_struct {
rib_used_t used;
rib_status_t status;
rib_role_t role;
uint8_t conf;
rib_dc_t *pending;
pthread_mutex_t mutex;
pthread_cond_t cond;
rib_f_t *props;
} rib_t;
And for example, rib_dc_t is like:
typedef struct rib_dc_stru...
The sequence is like follows:
Open a policy handle with LsaOpenPolicy() (not shown)
Call LsaQueryInformationPolicy() to get the number of categories;
For each category:
Call AuditLookupCategoryGuidFromCategoryId() to turn the enum value into a GUID;
Call AuditEnumerateSubCategories() to get a list of the GUIDs of all subcategories;
Ca...
I have a python method that returns a Python byte array.array('c').
Now, I want to copy this array using System.Runtime.InteropServices.Marshal.Copy. This method however expects a .NET array.
import array
from System.Runtime.InteropServices import Marshal
bytes = array.array('c')
bytes.append('a')
bytes.append('b')
bytes.append('c')
M...
I'm using EasyHook, a C# library for injecting and detouring functions from unmanaged applications. I'm trying to hook onto GetDlgItemTextA, which takes the arguments:
UINT WINAPI GetDlgItemText(
__in HWND hDlg,
__in int nIDDlgItem,
__out LPTSTR lpString,
__in int nMaxCount
);`
In my hook, I am casting it as:
[DllImpo...
Hi,
Purify is pointing memory leak in ole32.dll while returning a Variant with VT set to VT_RECORD as OUT parameter. I am using User Marshalling by generating proxy/stub dll from IDL.
Can you suggest how to avoid this memory leak?
Struct defined in IDL:
{
BSTR m_sFirst;
BSTR m_sSecond;
VARIANT m_vChildStruct; //This member encapsulate...
Hi,
I'm using Jersey (jax-rs), to build a REST rich application.
Everything is great, but I really don't understand how to set in JSON Marshalling and Unmarshalling converting option for dates and numbers.
I have a User class:
@XmlRootElement
public class User {
private String username;
private String password;
private jav...
Hello,
I'm trying to marshall unsigned char** (which is in a C++ interface) in order to call the method from C#.
How can this be done? Is there a list where are C++ data types and C# data types?
Thanks!
...
I have a question for which I suspect the answer is a bit complex. At this moment I am programming a DLL (class library) in C#. This DLL uses a 3rd party library and therefore deals with 3rd party objects of which I do not have the source code. Now I am planning to create another DLL, which is going to be used in a later stadium in my ap...
I have the following code
int testInt = 2;
String stringArg = "test";
List<Activity> activityList = new ArrayList<Activity>();
//activityList.add(new Activity(testInt, testInt, testInt, null, null, null, stringArg, stringArg));
//activityList.add(new Activity(testInt, testInt, testInt, null, null, null, stringArg, stringArg));
Activiti...
If a web service returns an object graph where some objects appear multiple times, will the data about these objects necessarily be duplicated in the transport format?
Put differently: With Java serialization, each object's state is written only once, and subsequent references to that object are mere pointers within the serialization st...
I'm looking for a drop-in replacement of Ruby's Marshal capability, which hopefully has one or more of the following advantages over Marshal:
faster serialization/deserialization
more concise (or simply smaller) object-graph
Thanks!!
...