Edited to indicate the VS'08 cannot compile a working dll, though I original said it could
We have a piece of VB code that compiles differently depending on what tools are used to compile it.
I have tried compiling this code on several different computers using Visual Studio '08, '10, and MSBuild 3.5 and 4. MSBuild 3.5 (which our build server uses) and VS'08 always produces a broken dll, while MSBuild4/VS'10 produces a working dll. I compared the Vbc command line parameters between MSBuild 3.5 and 4 the only differences were (/nodstdlib, /sdkpath, /langversion:9) which all appear related to making Vbc 4 compile a 3.5 compatible dll.
In the broken version the code inside the If statement throw an error saying Delegate to an instance method cannot have null 'this'.
A snippet of the relevant code is:
Dim folders As SortedList(Of String, FolderInfo) = FolderManager.Instance.GetFoldersSorted(portalId)
Dim inventory As New List(Of FolderInventoryItem)
'create a FileSysItem for every folder
For Each folderItem In folders.Values
Dim currentFolder = folderItem
If (Not inventory.Any(Function(f) f.UniqueId = currentFolder.UniqueId)) Then
....
Using Reflector to disassemble the IL to VB, the working dll contains:
Dim foldersSorted As SortedList(Of String, FolderInfo) = ComponentBase(Of IFolderManager, FolderManager).Instance.GetFoldersSorted(portalId)
Dim source As New List(Of FolderInventoryItem)
Dim info As FolderInfo
For Each info In foldersSorted.Values
Dim e$__ As _Closure$__2
e$__ = New _Closure$__2(e$__) { _
.$VB$Local_currentFolder = info _
}
If Not source.Any(Of FolderInventoryItem)(New Func(Of FolderInventoryItem, Boolean)(AddressOf e$__._Lambda$__6)) Then
Using Reflector to disassemble the IL to VB, the broken dll contains:
Dim foldersSorted As SortedList(Of String, FolderInfo) = ComponentBase(Of IFolderManager, FolderManager).Instance.GetFoldersSorted(portalId)
Dim source As New List(Of FolderInventoryItem)
Dim info As FolderInfo
For Each info In foldersSorted.Values
Dim e$__ As _Closure$__2
Dim e$__2 As _Closure$__3
e$__ = New _Closure$__2(e$__) { _
.$VB$Local_currentFolder = info _
}
If Not source.Any(Of FolderInventoryItem)(New Func(Of FolderInventoryItem, Boolean)(AddressOf e$__2._Lambda$__6)) Then