在我的一个项目中,我有两个配置文件:一个包含dev-environment的config-data,一个包含release-environment的config-data。
我希望根据构建配置挑选配置文件,因此我提出了以下代码段:
#if DEBUG
private static FileInfo ConfigFile = new FileInfo(Path.Combine("xml", "dev-config.xml"));
private static FileInfo RepoFile = new FileInfo(Path.Combine("xml", "dev-repositories.xml"));
#else
private static FileInfo ConfigFile = new FileInfo(Path.Combine("xml", "release-config.xml"));
private static FileInfo RepoFile = new FileInfo(Path.Combine("xml", "release-repositories.xml"));
#endif
选择Debug
- build-config时,代码编译良好并生成有用的可执行文件
但是,如果我选择Release
- build-config,编译器突然告诉我某个类型无法解析
所以我猜这是由于预处理器声明不好,但我在这里找不到错误