Hi Peter, My COM-dates are declared as DATE :-)
Roundtripping COM-dates can be simulated by this code: private void button3_Click(object sender, EventArgs e) { DateTime dt, dt2; double d; long ticks, maxTicks=0; for (int i=0 ;i<1000000; i++) { dt = DateTime.Now; d = dt.ToOADate(); dt2 = DateTime.FromOADate(d); ticks = Math.Abs(dt.Ticks - dt2.Ticks); if (ticks > maxTicks) maxTicks = ticks; } label1.Text = String.Format("{0} ticks diff", maxTicks); } If you set the loop cnt large enough you will see that there is a max of 10000 ticks mismatch. (1 ms) The COM-application uses up to micro-second resolution, and therefore will fail. By the way, using reflector, following the ToOADate() code, you can see that they actually multiply the # ticks by 10000 at the end... However, I saw that I wrote rounding to seconds in my original mail. This should be rounding to ms... But it is a bit weird: the resolution of .Net's DateTime is large enough, so why rounding? /P ----- Original Message ----- From: "Peter Ritchie" <[EMAIL PROTECTED]> To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM> Sent: Saturday, November 03, 2007 7:02 PM Subject: Re: [ADVANCED-DOTNET] Marshalling of COM dates
I think you'll have to declare your own managed interface for your native interfaces if you want to use custom marshaling (i.e. not use tlbimp) But, before going that route, how are the "COM dates" declared in the IDL? I've round-tripped dates through a native COM object without losing precision... Maybe there's something else at play here. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com