-
June 3rd, 2009, 09:52 AM
#1
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
-
June 4th, 2009, 01:08 AM
#2
Re: marshalling structure
Change from struct to class, mark with Serializable, and derive from MarshalByRefObject.
-
June 4th, 2009, 09:42 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|