Все вопросы: [marshalling]

130 вопросов

похожие теги:
1
голосов
2ответов
148 просмотров

Is there a way to decrease overhead associated with out-proc COM calls?

Our program consumes an out-proc COM server and makes thousands of calls on its interfaces. This takes very very long time - like a minute for about 50k calls. The COM component vendor says that the calls are very fast by themselves and that the problem is in the overhead associated with out-proc...

10
голосов
2ответов
6531 просмотров

Marshalling .NET generic types

Here is a C# program that tries Marshal.SizeOf on a few different types: using System; using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)] class AClass { } [StructLayout(LayoutKind.Sequential)] struct AStruct { } [StructLayout(LayoutKind.Sequential)] class B { AClass ...

0
голосов
2ответов
8071 просмотров

java.rmi.MarshalException

whenever I try to call my ejb from a client, I get this error : java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is: java.io.InvalidClassException: com.afrikbrain.util.message.MessageInfo; local class incompat...

2
голосов
3ответов
3907 просмотров

Suitable XML Marshaller and Unmarshaller

We have an XML that needs to be converted to an object and vice versa. Something like Xstream does. Until now we were using Xstream to marshall and unmarshall the object/xml. However the problem is that an object that corresponds to XML in xstream, needs to have all the tags as attributes; else ...

2
голосов
3ответов
3720 просмотров

Why does marshalling a struct of callback delegates cause an AccessViolationException

Introduction I am trying to use P/Invoke to register a struct of callbacks with a native dll. When calling a function that makes the native dll invoke the callbacks an AccessViolationException occurs. I have constructed a "small" test case that demonstrates the behavior comprised of 2 files, nat...

1
голосов
1ответов
2993 просмотров

How to marshal .NET string to variant for COM call

I'm using a third-party COM library from C#. There are get/set methods that take a parameter of type VARIANT (type VT_BSTR). In the .NET wrapper, these parameters appear as type object, i.e. object getValue(); void setValue( object val ); The getValue method works ok, I perform a simple cast ...

2
голосов
1ответов
1716 просмотров

System.AccessViolationException

I am using a com DLL in the following manner: #Region "API Function" <DllImportAttribute("abc.dll", EntryPoint:="optcntl")> _ Public Shared Function optcntl(ByRef pBlocks As blocks) As Integer End Function #End Region This DLL using the other four dlls to complete its process...

5
голосов
1ответов
3816 просмотров

Does C# have an equivalent to #pragma pack in C++?

C# provides StructLayoutAttribute.Pack, but its behaviour is "every member gets at least the specified alignment whether it wants it or not", whereas the behaviour of #pragma pack in C++ is "every member gets the alignment it wants, unless it wants more than the specified alignment, in which case...

4
голосов
4ответов
1718 просмотров

Is it possible to force a string to be a specific size when defining a struct?

I am marshalling data between a C# and C++ application. In the C# application, I force the size of a string to be some size (say, 256 bytes). I would like to read in that exact same amount in C++ (I will be recreating the structs with reinterpret_cast) so that the data will remain formatted as ...

4
голосов
2ответов
1064 просмотров

C#/C++ interop - Need help defining my data structure

I am working on a C# app that is trying to use functionality provided via a C++ DLL. I am having a bit of a hard time getting the DLLImport definitions to work right at the moment. Here's the C++ side of the equation: struct Result { FLOAT first; FLOAT second; }; struct ResultData...

2
голосов
4ответов
1850 просмотров

How is a securestring marshalled to unmanaged code?

What prompted this question: I'm trying to change the account under which a windows service runs. I decided to use the win32 api rather than WMI and started looking at ChangeServiceConfig. I thought I could simply use the SecureString type in the unmanaged method signature and it would work fin...

26
голосов
14ответов
59808 просмотров

Can I force JAXB not to convert " into ", for example, when marshalling to XML?

I have an Object that is being marshalled to XML using JAXB. One element contains a String that includes quotes ("). The resulting XML has " where the " existed. Even though this is normally preferred, I need my output to match a legacy system. How do I force JAXB to NOT convert the ...

3
голосов
4ответов
9166 просмотров

Wrong timezone being used in Java web service

I have a JAX-B java web service which I'm using to update a database. Each row in the table that I'm updating is represented by an object similar to below: - public class Item { private String id; private Date startDate; private Date endDate; public Item() { } ... } This...

5
голосов
2ответов
6233 просмотров

Marshalling array of strings to char ** in C#

I'm calling a C DLL function and need to supply the following C struct: typedef struct { char *mTableId; char **mFieldNames; int mNumFields; char *mFilter; char *mSort; int mOffset; int mMaxRecords; char *mTargetRecordF...

1
голосов
1ответов
1039 просмотров

JAXB - Add a node to the XML as html link

I have a basic JavaBean in my service layer and originally it was not designed for marshalling. This object is used by both JAX-WS, JAX-RS, and Servlets in other layers of my application. I want to take advantage of a drill down type effect in my REST services so my question is: How do I make ...

2
голосов
2ответов
1538 просмотров

What is wrong with my DLLImport of LogonUser with String Marshaling? [C#]

For some odd reason, when I marshal the LogonUser DLLImport parameters I am no longer able to login succesfully when using the INTERACTIVE logon type, it works for NETWORK logon type. This is my code: [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] public stat...

9
голосов
5ответов
4001 просмотров

interfacing erlang application with php

I have a website built with PHP. I have an Erlang application running as a daemon on the same server. I need to call functions on the Erlang application from PHP and get back the result. I've found PHP/Erlang and over PHP modules but I can't install a PHP module on this server, I can only use PH...

5
голосов
5ответов
4846 просмотров

Generic BitConverter-like method?

I've recently encountered a situation where I need to create a generic method to read a datatype out of a byte array. I've created the following class: public class DataStream { public int Offset { get; set; } public byte[] Data { get; set; } public T Read<T>() where T : st...

6
голосов
3ответов
7669 просмотров

C#: marshalling a struct that contains arrays

I am doing some C# interop work. I have the following struct: #pragma pack(push,1) typedef struct { unsigned __int64 Handle; LinkType_t Type; LinkState_t State; unsigned __int64 Settings; signed __int8 Name[MAX_LINK_NAME]; unsigned __int8 DeviceInfo[MAX_LINK_DEVINFO]; ...

3
голосов
5ответов
17041 просмотров

equivalent char* in C#

I have a dll that is written in c++. And I am p/invoking to call the functions. I have this c++ declaration. int dll_registerAccount(char* username, char* password); I have done this dllimport declaration: [DllImport("pjsipDlld")] static extern int dll_registerAccount(IntPtr username, IntPtr...

4
голосов
2ответов
1744 просмотров

C# Newbie: How do I fix this code to do a DNS lookup?

This is my first time using C#, so I'm very much out of my element. But I have faith that the wonderful people here at Stack Overflow can help me out! I've come up with the following code (below) based on some other pieces of code I found floating around on the internet. What I am trying to do is...

2
голосов
1ответов
1233 просмотров

COM interface declarations

When creating COM interface declarations in C# are there any "rules" you have to stick to? I think there are and would like to get some info on it. For example I'm toying around with the ITaskbarList, ITaskbarList2 and ITaskbarList3 interfaces and it seems to me that I Have to declare the order...

2
голосов
2ответов
2283 просмотров

Managing C++ Garmin API in C#

I want to call Garmin API in VB.Net Compact Framework project. The API is in C++, so I'm making a C# dll project as intermediate way between API dll and VB.NET. I have some problems while executing my code because it throws a NotSupportedException (bad arguments type, I think) in the QueCreatePoi...

3
голосов
3ответов
1734 просмотров

Pass a Delphi set to an external Delphi function from C#

I'm trying to call an external Delphi function from C# which takes a Delphi set as a parameter: Delphi code type tStatus = (sIn, sOut, sAbsent, sSick); tStatusSet = set of tStatus; function LoadEmployees(tStatusSet aStatusSet): tEmpList; I need to marshall a C# array of enum values (that...

6
голосов
2ответов
14393 просмотров

Marshaling a Byte array to a C# structure

I'm working on a C# project for reading FAT32 Boot Sector and BPB, The problem is that I'm using a marshaling mechanism to convert a byte array to a Custom FAT32 data structure. I get a message error saying : Could not load type 'FAT32Management.Fat32BootSector' from assembly 'FAT32Management, Ve...

2
голосов
1ответов
621 просмотров

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

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 ...

3
голосов
2ответов
20100 просмотров

Marshal.SizeOf error in computing size

i have a structure public struct SERVER_USB_DEVICE { USB_HWID usbHWID; byte status; bool bExcludeDevice; bool bSharedManually; ulong ulDeviceId; ulong ulClientAddr; [MarshalAs(UnmanagedType.ByValArray, ...

7
голосов
2ответов
10133 просмотров

Marshaling pointer to an array of strings

I am having some trouble marshaling a pointer to an array of strings. It looks harmless like this: typedef struct { char* listOfStrings[100]; } UnmanagedStruct; This is actually embedded inside another structure like this: typedef struct { UnmanagedStruct umgdStruct; } Outerstruct; ...

7
голосов
5ответов
4813 просмотров

IntPtr arithmetics

I tried to allocate an array of structs in this way: struct T { int a; int b; } data = Marshal.AllocHGlobal(count*Marshal.SizeOf(typeof(T)); ... I'd like to access to allocated data "binding" a struct to each element in array allocated with AllocHGlobal... something like this T v; v = (T...

17
голосов
2ответов
10140 просмотров

Correct way to marshal SIZE_T*?

I have the following C++ function definition, which I am trying to call through PInvoke from managed code: bool FooBar(SIZE_T* arg1); My managed declaration looked as follows: [DllImport("mydll", SetLastError=true, CharSet=CharSet.Unicode)] private static extern bool FooBar(ref uint arg1); ...