c# - Compilation fails if delegate definitions is put in another project? -


Update: I have filed it as you can reproduce it and / Or seeing this problem, please help vote on this issue there.


I am trying to solve this problem for hours now.
Which Idea /

First of all, I have 3 files Class.cs Definitions. and Program.cs . I have tried that you are trying to paste the contents of the file above.

The problem is that, if you have all 3 files in the same console application project, compile the application and runs just fine.

However, I have Class.cs and Definitions.cs in the "Library" project that is referred to as the main console application project , Which contains only the Program.cs file, fails to compile:

  • Representative act 2 does not take arguments.
  • The Lambda expression can not be changed to delegate the 'DC.Lib.Produce' type because some return types in the block are not completely convertible to the representative pattern type ... < / Li>

There is a complete solution with 3 projects- 1 all files have been added together and with the definitions given in another project:

< P> I am using VS2010 RTW Professional Edition.

Interesting I looks you found a real bug in the C # compiler Although I may have lost some subtle details I have written a slightly simplified version which avoids the possibilities of overloading etc. in the play, and with the additional method:

  / / Definitions Public Interface IDA {} Public Representative IData Foo (IDTA Input); Public Representative IData Bar & lt; T & gt; (IData input, T additional information); Public Representative Foo Produce & lt; T & gt; (Bar> T & gt; Next); // Test CS Class Test {Static Wide Men} (Construction & lt; String & gt; Production = next = & gt; Input = & gt; Next (Input, "This string should be visible."); }}  

Demonstrate compilation as an assembly, with no errors:

  & gt; Csc Test.cs Definitions.cs  

Demonstration of collections as two assemblies with errors:

  & gt; CSC / Goal: Library Definitions.cs & gt; Csc Test.cs / r: Definition Dll Test.cs (5,43): Error CS1662: Lambda expression is called 'product & lt; String & gt; Because some types of returns in the block are not variable in return type Test.cs (5,52): Error CS1593: Representative 'bar' does not take 2 arguments  

I < Em> can not think of any reason because it should be different in different assemblies, as everything is public seldom internal except for reasons Talks about the boundaries of the assembly.

Interesting, I get the same error for both the C # 3 and 4 compilers.

Email Eric and Maddie now ...

EDIT: Note that you can work on it using a clear parameter list. For example, in my sample code, this would work:

  Products < String & gt; Production = (bar  gt; next) = & gt; Input = & gt; Next (Input, "This string should be visible.");  

Comments