Discovered Constant Bug in VS.NET 2003

Posted by Kirby Turner on September 19, 2005

Tonight I discovered an interesting Visual Studio.NET 2003 bug. Seems devenv.exe will throw an unhandled exception when the constant in the sample code below is compiled. From what I can tell, it looks like devenv.exe chokes on the length of the contant. Remove line 73 (LEFT OUTER JOIN…) and the exception is not thrown.

The exception only occurs when compiling the project from within VS.NET 2003 (devenv.exe). The command line compiler csc.exe does not have the problem. Also, the problem does not occur if you are using Delphi 2005. Makes me wonder what devenv.exe is doing during the project build process.

<pre>
001 using System;
002
003 namespace ConsoleApplication3
004 {
005 /// <summary>
006 /// Summary description for Class1.
007 /// </summary>
008 class Class1
009 {
010 /// <summary>
011 /// The main entry point for the application.
012 /// </summary>
013 [STAThread]
014 static void Main(string[] args)
015 {
016 const string SQL_FORMAT = @”
017 SELECT
018 1 AS Tag,
019 NULL AS Parent,
020 NULL AS [users!1],
021 NULL AS [user!2!strUSID],
022 NULL AS [user!2!strPrefixID],
023 NULL AS [user!2!strFirstName],
024 NULL AS [user!2!strLastName],
025 NULL AS [user!2!strUSName],
026 NULL AS [user!2!strAdd1],
027 NULL AS [user!2!strAdd2],
028 NULL AS [user!2!strTown],
029 NULL AS [user!2!strState],
030 NULL AS [user!2!strPostCode],
031 NULL AS [user!2!strCountry],
032 NULL AS [user!2!strTel],
033 NULL AS [user!2!strFax],
034 NULL AS [user!2!strEMail],
035 NULL AS [user!2!strLocked],
036 NULL AS [user!2!dtmLockedDate],
037 NULL AS [user!2!strSuspenseReason],
038 NULL AS [user!2!intLogonCount],
039 NULL AS [user!2!dtmCreatedDate],
040 NULL AS [user!2!strMedicalSpecialtyID],
041 NULL AS [user!2!blnChangePassword],
042 NULL AS [user!2!strInstitutionalUser],
043 NULL AS [user!2!strCreditCardExpDate]
044 UNION
045 SELECT
046 2 AS Tag,
047 1 AS Parent,
048 NULL,
049 Users.strUSID,
050 strPrefixID,
051 strFirstName,
052 strLastName,
053 strUSName,
054 strAdd1,
055 strAdd2,
056 strTown,
057 strState,
058 strPostCode,
059 strCountry,
060 strTel,
061 strFax,
062 strEMail,
063 strLocked,
064 dtmLockedDate,
065 ID_LoginSuspenseReason.strSuspenseReason,
066 intLogonCount,
067 dtmCreatedDate,
068 strMedicalSpecialtyID,
069 blnChangePassword,
070 strInstitutionalUser,
071 strCreditCardExpDate
072 FROM ID_Login Users
073 LEFT OUTER JOIN ID_LoginSuspenseReason ON Users.strUSID = ID_LoginSuspenseReason.strUSID
074 {0}
075 FOR XML EXPLICIT
076 “;
077 }
078 }
079 }
</pre>


Posted in uncategorized. Tagged in .