Bugzilla – Bug 324050
[PATCH] some LP(C)WSTR marshal weirdness on win32
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by atsushi@ximian.com 2007-04-13 08:21:09 MST ---- During cardspace work I'm getting a weird error which seems to be caused by marshalling behavioral difference. Unfortunately this test depends on .NET 3.0 (infocardapi.dll) and thus it is reproducible only on windows... I have a structure that looks like: [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)] struct NativePolicyElement { string target; string issuer; string parameters; string privacy_link; int privacy_ver; bool is_managed; } and a P/Invoke method: [DllImport ("infocardapi", CharSet = CharSet.Unicode)] static extern int GetToken (int cPolicyChain, NativePolicyElement [] pPolicyChain, out NativeGenericXmlToken securityToken, out NativeInfocardCryptoHandle phProofTokenCrypto); When I compiled the attached repro with gmcs, and run under .NET, it raises Infocard selector without errors. When I run the same binary with mono (win32 runtime), it raises an error saying: "Incoming policy failed validation." It files an application error on win32 EventLog: <blockquote> Incoming policy failed validation. Received policy with invalid epr. Inner Exception: The data at the root level is invalid. Line 1, position 1. Additional Information: Microsoft.InfoCards.PolicyValidationException: Received policy with invalid epr. ---> System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1. ... </blockquote> (note that there is no invalid XML; .NET runs it just fine). The error message above refers to "invalid epr", which corresponds to the "target" field in NativePolicyElement. Other parameters such as those "out" ones are ignorable (they will cause an error only after you selected a card) and they can be removed to reproduce the issue above. ---- Additional Comments From atsushi@ximian.com 2007-04-13 08:22:12 MST ---- Created an attachment (id=171785) repro ---- Additional Comments From joncham@gmail.com 2007-05-10 15:35:02 MST ---- Created an attachment (id=171786) Patch ---- Additional Comments From joncham@gmail.com 2007-05-10 15:36:12 MST ---- All runtime tests pass with this patch, and it fixes a bug very similar to this one in my app. I didn't test since I don't have .Net 3.0 installed. Atsushi, this should fix your issue as well. ---- Additional Comments From joncham@gmail.com 2007-05-10 15:39:34 MST ---- Created an attachment (id=171787) Complete Patch ---- Additional Comments From vargaz@gmail.com 2007-05-10 18:02:24 MST ---- This looks ok to check in. ---- Additional Comments From atsushi@ximian.com 2007-05-10 22:21:10 MST ---- The patch actually fixed the issue I reported here :-) ---- Additional Comments From joncham@gmail.com 2007-05-10 22:47:07 MST ---- Fixed in r77190. Imported an attachment (id=171785) Imported an attachment (id=171786) Imported an attachment (id=171787) Unknown operating system unknown. Setting to default OS "Other".