c# - PostSharp 不能使用具有 > 127 个属性的匿名类型

标签 c# .net visual-studio postsharp

问题已在 PostSharp 4.3.27 中修复

给定以下 C# 代码

 var obj = new
 {
     p0 = 0,
     p1 = 1
     p2 = 2,
     // and so on until 127 ...
     p127 = 127
 }

我在尝试构建启用了 PostSharp 的项目时遇到此错误:

Severity Code Description Project File Line Suppression State
Error error:
Unhandled exception (4.3.25.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.394802, Release): The file c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\obj\Debug\Before-PostSharp\PostSharpTest.exe is not a valid .NET assembly. See below for details. PostSharpTest c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\POSTSHARP
Error System.BadImageFormatException: The file c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\obj\Debug\Before-PostSharp\PostSharpTest.exe is not a valid .NET assembly. ---> PostSharp.Sdk.AssertionFailedException: Invalid value 128 for enumeration ^Bw+U+DEY6J8e at location element type in type signature. at PostSharp.Sdk.Binary.ModuleReader.ReadTypeSignature(BufferReader& _0) at PostSharp.Sdk.Binary.ModuleReader.ReadTypeSignature(BufferReader& _0) at PostSharp.Sdk.Binary.ModuleReader.ImportTypeSpec(Int32 _0) at PostSharp.Sdk.Binary.ModuleReader.ImportTypeSpecs() at PostSharp.Sdk.Binary.ModuleReader.ReadModule() at PostSharp.Sdk.Binary.ModuleReader.ReadModule() at PostSharp.Sdk.Binary.ModuleReader.ReadModule(ReadModuleStrategy _0) at PostSharp.Sdk.CodeModel.Domain.LoadAssembly(String assemblyLocation, LoadAssemblyOptions options) at PostSharp.Sdk.Extensibility.ModuleLoadDirectFromFileStrategy.Load(Domain domain) at PostSharp.Sdk.Extensibility.Project.^LvMUl75+(ModuleLoadStrategy _0) at PostSharp.Sdk.Extensibility.Project.^63o9P8x3(ModuleDeclaration _0, ModuleLoadStrategy _1, Domain _2, ProjectInvocationParameters _3, Boolean _4) at PostSharp.Sdk.Extensibility.Project.CreateInstance(Domain domain, ProjectInvocation projectInvocation, Boolean reuseDomain) at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) at PostSharp.Hosting.Program.ExecuteImpl() PostSharpTest c:\users\johnm\documents\visual studio 2015\Projects\PostSharpTest\PostSharpTest\POSTSHARP

消息

Invalid value 128 for enumeration ^Bw+U+DEY6J8e at location element type in type signature.

似乎有一定的意义,但我不熟悉 PostSharp 的内部结构。

删除 p127 工作正常。还有其他人遇到过这个限制吗?

最佳答案

这已在 PostSharp 4.3.27 中修复

关于c# - PostSharp 不能使用具有 > 127 个属性的匿名类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41295149/

相关文章:

c# - 不一致的可访问性错误

c# - Asp GridView 在整行上触发 Click 事件

c# - ExchangeServiceBinding 命名空间错误

c# - 构造函数中的虚拟成员调用

c# - 具有单独 ID 属性的 EF6 一对一关系

c# - 如何根据键值对创建对象

mysql - 如何在VS 2013中将MySQL表添加到对象关系设计器?

c++ - visual C++ express 2010 和设置环境变量解决方案范围

c# - HttpContext IP问题

.net - 格式化 json 文档