I'm writing a Web api for a mobile application, which replies back with httpResponseMessages. I've run into a problem which i'm too novice to fix.
Basically, in my business layer class library I have a private reference to a file:
private const string FiFile = @"C:\DirectoryFile\FI.dat";
this const is being called by another part of my solution (Web pages), and is never used/or called when using the mobile calls.
However, if i deploy the mobile api, without this directory on the server it throws an exception.
I basically have 4 projects in one solution, one for web, one for mobile, and both have a reference to the business layer.
Please can you advise how I can prevent this from happening?
The only way i've been able to stop it, is to phsyically created the above folder/file.
** Update ** the error is as follows:
{"Message":"An error has occurred.","ExceptionMessage":"The type initializer for BusinessLayer.BIFacade' threw an exception."
ExceptionMessage":"Could not find a part of the path 'C:\\DirectoryFile\\FI.dat'.
* UPDATE * When i debug, and use fiddler to make my api calls, the visual studio stops here:
private static readonly Dictionary<string, BiData> SBicDirectory =
File.ReadAllLines(FiFile).ToDictionary(line => line.Substring(3, 11), line => CreateBiData(line));
which is where it is trying to use the FiFile const, which is in the constructor.
* EDIT * Doohhhh - its late. it's in the constructor, so guess what :-)
Being a muppet - it's in the constructor therefore, will always be called. Sorry everyone.