FileHelpers.dll 不忽略私有字段?
我过去曾成功使用过此处找到的 FileHelpers.dll 库。在这个特定的情况下,大约去年的这个时候,我能够让班级生成一些平面文件。由于某种原因,整整一年后,我回到我的旧项目,做了一些修改,但现在它不起作用了。我正在尝试使用FixedLengthRecord 将一些数据写入文件,但现在它抱怨并非所有字段都具有FixedField 属性。我进行了两次、三次、四次检查,我的所有公共字段都具有必需的属性。在评论了我的所有方法和属性之后,我意识到它在抱怨我用来支持某些类属性的一些私有字段。我必须在这些私有字段上应用“忽略”属性才能使其正常工作。
我的问题是,这次我可以做什么才能让它以这种方式表现?去年,完全相同的类定义就像一个魅力,它忽略了我所有的私有字段。我正在使用 VS2008 和 FileHelpers.dll 版本 2.0.0.0(与我去年使用的版本相同)。我尝试搜索文档并阅读一些源代码,但我似乎找不到与此相关的任何内容。
I've used the FileHelpers.dll library found here in the past with success. In this specific case, this time around last year, I was able to make the class generate some flat files. For some reason, a full year later, I come back to my old project, make some modifications and now it won't work. I'm trying to use FixedLengthRecord to write some data to a file, but now it complains that not all my fields have the FixedField attribute. I double, triple, quadruple checked and all my public fields have the required attribute. After commenting all of my methods and properties I realized that it was complaining about some private fields I use to back some of the class' properties. I had to apply a Ignore attribute on these private fields for it to work.
My question is, what could I have possibly done this time around for it to behave in this manner? Last year the exact same class definitions worked like a charm and it ignored all of my private fields. I'm using VS2008 and FileHelpers.dll version 2.0.0.0 (same version I used last year). I tried searching the docs and reading some of the source code, but I can't seem to find anything related to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,该库包含所有字段(公共或私有),您必须使用
[FieldHidden]
属性显式排除它们。您可以从主页下载最新的稳定版本:
www.filehelpers.net
in fact the library includes all the fields (public or private) you must to explicity exclude them out with
[FieldHidden]
attribute.You can download the last stable version from the home page:
www.filehelpers.net