C # compiler improperly optimizes code

I have an ASP.NET application running on a remote web server, and I just started getting this error:

Method not found: 'Void System.Collections.Generic.ICollection`1..ctor()'.

I parsed the code in a DLL, and it seems that the compiler is not optimizing the code correctly. (Note that Set is a class that implements a set of unique objects. It inherits from IEnumerable.) This line:

Set<int> set = new Set<int>();

Compiled to this line:

Set<int> set = (Set<int>) new ICollection<CalendarModule>();

The CalendarModule class is a completely unrelated class! Has anyone ever noticed .NET incorrectly compiling such code before?

Update # 1: This issue seems to be introduced by Microsoft ILMerge . We are currently studying how to overcome it.

# 2: . , , :

  • .

  • ILMerge .

, , ( , , ) - .

+3
6

Ahh, ILMerge - . , .NET , ILMerge (, ).

, "" , .

Microsoft?

, , ILMerge. csproj - XML, , MSBuild.

+7

, , , ? ?

:, Reflector, , MSIL # . Reflector 100% . MSIL?

2: ... , Reflector .

+1

, , .Net. , - , , , ( serialisable ).

, , , .

+1

; - . , ( ) - , - ?

Sidenote: System.Collections.Generic.HashSet<T>, .Net fx 3.5 , Set<>.

+1

? - ? , ?

, , , .

0

Uch. If this is really an ILMerge error, please keep this topic up to date with your results - I use ILMerge as a key step in building a COM interop assembly.

0
source

Source: https://habr.com/ru/post/1697415/


All Articles