存储静态错误字符串最好的地方 [英] Best place to store static error strings

查看:139
本文介绍了存储静态错误字符串最好的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人对在哪里存储静态错误字符串在C#应用程序的最佳做法的任何输入。我有一个具有5个项目,并已确定通过在邮件的形式WCF REST Web服务将返回几个常数错误消息的Visual Studio 2010的解决方案。

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.

我的我已经定义(硬编码)电流误差在以下格式(CODE,MESSAGE):

My current errors I have defined (hard-coded) are in the following format (CODE, MESSAGE):

999 - 您的请求无法与指定的参数进行处理

999 - Your request could not be processed with the parameters specified.

我不问如何创建从Exception类派生自定义类,因为相应的异常后返回这些错误提出从断层保持程序池。

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.

一些想法,我琢磨存储消息:XML,平面文件,SQLite和等

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?

感谢您,

杰弗里·凯文撬

推荐答案

我个人存储这些东西,在项目的资源文件,然后检索这些当我需要他们。这样做,这样也使得它容易得多改变它们,例如,如果你需要的系统使用另一种语言你会做的是切换资源文件之一,另一种语言,瞧!

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!

这篇关于存储静态错误字符串最好的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆