KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
One of my team has recently come across an interesting glitch in the matrix. If anyone can help explain this it'd be great. It is possibly a complicated to explain, so bear with me. We are building an ASP.Net application. In it we have a simple "if" statement. Guid adminId = Guid.Empty; if (mRoles.Contains("Admin")) { adminId = mUserId; } (where mRoles is a List and contains “Admin”) This works just as expected (i.e adminID is assigned the mUserId). However, when rewritten to use a ternary operator below it doesn't! (adminID is assigned Guid Empty)! Guid adminId = mRoles.Contains("Admin") ? mUserId : Guid.Empty; The developer that discovered this is on a 64-bit machine (IIS7/64-bit vista) and if he changes his settings in IIS as follows... Under "Default Application Pool" > "Advanced Settings" check "Enable 32-bit applications." Now both statements work! We think that this is something to do possibly with the fact that a Guid is a struct rather than a class and that the value is somehow being offset under a 64-bit process. I suspect the problem is similar to this... http://www.mail-archive.com/comtypes-users@lists.sourceforge.net/msg00164.html Which may explain why the first simple if statement works. (as creating the adminId variable is maybe creating a pointer and the ternary operator is not?) If anyone could shed any light on this that’d be great. Is it a compatibility bug? or our misunderstanding of combining ternary operators and structs? Thanks. UPDATE Put together a simple application and cannot reproduce it on a completely new project, so must be something else than the GUIDs. // Works (assigns mUserId to adminId) Guid adminId = true ? mUserId : Guid.Empty; </c
Tags (comma-separated)
Save Edits
Cancel