Hi Marcus,

On Sat, 2007-09-29 at 10:03 +0200, Marcus Krantz wrote:
> Hi all,
> I'm playing around a little bit Evolution-sharp. Since .NET is all new
> to me I have some problems setting fields of contact instances. I
> would really like to use the Set function but when I try I get
> compilation errors all the time. Consider the following snippet: 
> 
> Contact c = new Contact();
> ContactAddress addr = new ContactAddress();

IntPtr i = Marshal.AllocHGlobal(Marshal.SizeOf(addr));

>             
> addr.Country = "Sweden";
> addr.Street = "Test";
> addr.Code = "SE-123 23";
> addr.Region = "Gothenburg";
>             
> c.Set(ContactField.AddressWork, addr);    // CS1503
> c.Set(ContactField.Email, "[EMAIL PROTECTED]");    //CS1503
> 

Marshal.StructureToPtr (addr ,i, false);
c.Set(ContactField.AddressWork, i); 

You need to free the allocated memory.

This may help :
http://www.mono-project.com/Interop_with_Native_Libraries

Regards,
Johnny

_______________________________________________
Evolution-hackers mailing list
Evolution-hackers@gnome.org
http://mail.gnome.org/mailman/listinfo/evolution-hackers

Reply via email to