Alexei_shk

Hi,

I got the error: Can not marshal parameter #3: The type definition of this type has no layout information.

My code in C# is:

Code Snippet

[DllImport("CadIO.dll", EntryPoint = "dxfDrawViewToList")]

unsafe static extern bool dxfDrawViewToList(IntPtr dc, ArrayList lstData, ArrayList lstIndexes, int x, int y, double z);

How can I solve it

Thank's

Alexei




Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

OmegaMan

I am suprised that parameter #2 works but #3 fails...why is three different from two Do you have access to the original source





Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

In C I have:

Code Snippet

BOOL __stdcall dxfDrawViewToList(HDC dc, ArrayList *lstData, ArrayList *lstIndexes, long dx, long dy, double z) {

....

}

What is wrong

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

OmegaMan

In the managed code how are you calling it Maybe specifying [in,out] or [in] may help it.







Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

I have tryed:

[DllImport("CadIO.dll", EntryPoint = "dxfDrawViewToList")]

unsafe static extern bool dxfDrawViewToList(IntPtr dc, ref ArrayList lstData, ref ArrayList lstIndexes, int x, int y, double z);

[DllImport("CadIO.dll", EntryPoint = "dxfDrawViewToList")]

unsafe static extern bool dxfDrawViewToList(IntPtr dc, [In, Out]ref ArrayList lstData, [In, Out]ref ArrayList lstIndexes, int x, int y, double z);

[DllImport("CadIO.dll", EntryPoint = "dxfDrawViewToList")]

unsafe static extern bool dxfDrawViewToList(IntPtr dc, [In, Out]ArrayList lstData, [In, Out]ArrayList lstIndexes, int x, int y, double z);

It doesn't work.

How can I solve my problem

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

OmegaMan

Since it is a C to C# maybe adding to the attribute declaration will help such as

DllImport(..., CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl)]

Otherwise you will have to change the calling to a ref IntPtr and marshal the structure yourself....





Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

Can you give example

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

I have tryed to convert function to the class and use it by reference.

The error what I have got is:

Can not marshal parameter #4: The type definition of this type has no layout information.
at CDrawing.PaintToList(CDrawing* , HDC__* hdc, ArrayList lstData, ArrayList lstIndexes)
at dxfDrawViewToList(HDC__* dc, ArrayList lstData, ArrayList lstIndexes, Int32 dx, Int32 dy, Double z)
at CadIO.CadLoader.dxf_DrawViewToList(IntPtr dc, ArrayList lstData, ArrayList lstIndexes, Int32 dx, Int32 dy, Double z)
at ESGBRDXF.DXF.DrawDXF(String strFile, Int32 factor, Rectangle& rect, ArrayList lstData, ArrayList lstIndexes) in ...

It's the same error that I got in using DLLImport on same parameter.

Why and how can I solve it

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

OmegaMan

Check out this article on C# interop: unsigned char* C .lib to see if this person's situation applies.





Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

I read it and did it before. It doesn't help me when I am using the ArrayList.

I think I need to convert all C code to C++ code used the .Net libraries. May be it will be solve my problem.

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

OmegaMan

Sorry couldn't help in that route, but C does seem to have issues vs C++ let us know what you find. Thanks.





Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Peter Ritchie

What is ArrayList




Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

ArrayList is .Net object for collection of objects.

Thank's

Alexei






Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Peter Ritchie

You can't use ArrayList in native C, your prototype BOOL __stdcall dxfDrawViewToList(HDC dc, ArrayList *lstData, ArrayList *lstIndexes, long dx, long dy, double z) suggests you have a different, native, class called ArrayList--which will not marshal automatically to .NET's ArrayList. If that's the case you'll have to marshal it manually.




Re: Visual C# General Can not marshal parameter #3: The type definition of this type has no layout information.

Alexei_shk

Hi,

I don't really understand you. Can you give a little example

Thank's

Alexei