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);
Some of you may notice the same bug I even...
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)Marshal.PtrToStructure(data+1, typeof(T))...
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;
Unmanaged code calls back into managed co...
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, SizeConst = 256)]
string usbDe...
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.TryLo...
Hello,
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, Version=1.0.0.0, Culture=neutral, Pub...
I have had not trouble passing primitive values from Javascript to Silverlight through the HTML bridge, but I keep getting stuck when trying to pass a Dictionary. Furthermore, I can't find a single sample of this working anywhere online, though the MSDN documentation says it should just happen automatically. Instead, I get an error tha...
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 is elements from tStatus) into a format t...
I want to call Garmin API (http://developer.garmin.com/mobile/mobile-sdk/) 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 throw a NotSupportedException (bad arguments type, i think) in QueCreateP...
Hi,
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 of the members in the manages implem...
This is my first attempt to call a .NET assembly from a Delphi 5 (Win32) native assembly. I am only familiar with C# and .NET so please bear with me.
I guess I will walk thru this layer by layer. Here is the code for the C# assembly I am attempting to execute from the Delphi 5 assembly.
using System;
using System.Collections.Generic;
us...
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 to look up all the "text" DNS records (TX...
Hello,
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 password);
Would my DllImport b...
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];
unsigned __int8 Reserved[40];
} LinkInfo_...
Hello, 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 : struct
{
unsafe
{
...
Hi,
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 PHP code.
The only way I know to solve...
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 static extern bool LogonUser
(
...
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 one of the fields/properties of the javabe...
Hi,
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 *mTargetRecordFilter;
int mSurroundingRec...
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 class is being instantiated in a separate...