473,394 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Invoke a DLL from C# and pass by reference a struct containing a StringBuilder....!!!

I would like to invoke a DLL written in C++ fron C#. The problem is that I need to pass by reference a structure that contrins a StringBuilder. How can I do it??

MY CODE IS THIS:

using System;
using System.Runtime.InteropServices;
using System.Text;

/// <summary>
/// Summary description for dllRPC.
/// </summary>
public class dllRPC
{
public struct ParRPC
{
public Int32 len;
public StringBuilder val;
//public string val;
}

public struct mensRPC
{
public Int32 par1;
public ParRPC par2;
}


public dllRPC()
{
//
// TODO: Add constructor logic here
//
}

[DllImport("VAX_RPC.dll")]

public static extern void ComandoVax(Int32 ntask, ref StringBuilder nhost, ref mensRPC mensaje);

}


WHEN LATER I DO THIS:

dllRPC.ComandoVax(ntask , ref nomvia , ref mens);

I TAKE THIS MESSAGE:

An unhandled exception of type 'System.TypeLoadException' occurred in Central_Alarmas.exe

Additional information: Can not marshal field par2 of type mensRPC: The type definition of this field has no layout information.


CAN SOMEONE HELP???

Thanx!!!
Feb 14 '07 #1
1 2444
kenobewan
4,871 Expert 4TB
This article may help:
Calling PowerBuilder NVOs in C#
Feb 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mo | last post by:
I am having problem with marshaling struct in C#. //the original C++ struct typedef struct _tagHHP_DECODE_MSG { DWORD dwStructSize; // Size of decode structure. TCHAR ...
7
by: Mo | last post by:
I am having problem with marshaling struct in C#. //the original C++ struct typedef struct _tagHHP_DECODE_MSG { DWORD dwStructSize; // Size of decode structure. TCHAR ...
16
by: Duncan Mole | last post by:
Hi, This is probably an easy one but it iy first bit of p/invoke. I am trying to use the following C struct in a call: typedef struct { BYTE SRB_Cmd; BYTE SRB_Status, BYTE ...
10
by: GTi | last post by:
I have some functions that I want to Invoke in my C# project: int NumberOfServers (BOOL UseENUM, LPCSTR MachineName); BOOL GetServerName (int index, LPSTR Buffer, int BufSize); can be used by:...
5
by: Steve | last post by:
Hi Folks, I'm trying to create a c# class to manage a DHCP subnet using the win api (dhcpsapi.dll). Currently I can't even instanciate my class, instead I receive the error:...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
5
by: Richard | last post by:
Hello, I'm working on an application to allow our network team to use a small application to make DHCP reservations on our Microsoft DHCP Server. The problem is you have to use P/Invoke to do...
5
by: rafal.m | last post by:
Hi This code fails: class K2 { public function increment(&$obj) { $obj += 1; }
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.