CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    76

    marshalling structure

    [VS 2005 , Vista]

    Hi

    I am having a bit of difficulty marshalling a structure which is the parameter in a unmanaged function call.

    The structure is

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct FilterParams
    {
    public Int32 param1;
    public Int32 param2;
    public Int32 focus;
    public bool show;
    public bool contrast_stretch;
    public bool sharpen;
    }

    and the com object function being called is:

    [Guid("03556EB9-9BE8-4503-B788-ADC730A901B9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IECFilterInterface
    {
    int get_DShowFilter([In,Out] ref FilterParams rnValue);
    }

    The function is getting called ( I have checked this in the com object) , and should modify the values of the members of the structure passed, however when it is passed back the values of the structure are not modified.

    Any ideas what i might be doing wrong

    any help/comments would be appreciated

    simon

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: marshalling structure

    Change from struct to class, mark with Serializable, and derive from MarshalByRefObject.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Jan 2003
    Posts
    76

    Re: marshalling structure

    Hi Cilu

    I tried that as follows:

    [Serializable]
    public class FilterParams : MarshalByRefObject
    {
    public Int32 param1 = 0;
    public Int32 param2 = 0;
    public Int32 focus = 100;
    public bool show = true;
    public bool contrast_stretch = false;
    public bool sharpen = false;
    }

    It built ok, but it throws an ExecutionEngineException when I call get_DShowFilter

    any ideas ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured