存储静态错误字符串的最佳位置
我想知道是否有人对在 C# 应用程序中存储静态错误字符串的最佳实践有任何意见。我有一个 Visual Studio 2010 解决方案,它有 5 个项目,并定义了几个要通过 WCF REST Web 服务以消息形式返回的常量错误消息。
我定义的当前错误(硬编码)采用以下格式(代码、消息):
999 - 无法使用指定的参数处理您的请求。
我不是问如何创建从 Exception 类派生的自定义类,因为这些错误是在引发相应的异常后返回的,以防止 AppPool 出错。
我正在考虑将消息存储在以下位置的一些想法:XML、平面文件、SQLite 等。
有人有偏好吗?如果有,为什么?
谢谢你,
杰弗里·凯文·普瑞
I was wondering if anyone had any input on the best practice of where to store static error strings in a C# application. I have a visual studio 2010 solution that has 5 projects and have defined several constant error messages to be returned via a WCF REST web service in the form of a message.
My current errors I have defined (hard-coded) are in the following format (CODE, MESSAGE):
999 - Your request could not be processed with the parameters specified.
I am not asking how to create custom classes derived from the Exception class because these errors are returned after corresponding Exceptions are raised to keep the AppPool from faulting.
Some ideas I was pondering storing the messages in: XML, Flat File, SQLite, and so on.
Does anyone have a preference and if so, why?
Thank you,
Jeffrey Kevin Pry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我个人将这些东西存储在项目资源 文件,然后在需要时检索它们。这样做也使得更改它们变得更加容易,例如,如果您需要系统使用另一种语言,您所要做的就是将资源文件切换为另一种语言,瞧!
I personally store these things in the projects Resources file, and then retrieve them when I need them. Doing it this way also makes it a lot easier to change them, for example if you needed the system to use another language all you'd do is switch the resources file for one in another language and voila!