views:

109

answers:

2

I'll try to do my best to explain my problem.

I have 2 separate projects which are part of the same application in Visual Studio. One of them is server-sided and the other is client-sided.

The client sided project uses an appSettings key called XMLFileName which is used to retrieve data from an XML and populate a dataset with the retrieved info. In this client sided project I have a method that performs some check in the dataset.

When I try to call that method from the server sided project, I can't get the dataset populated since the XMLFileName isn't being read by the server sided project due to it not being defined in its application settings. If I hardcode the file name string on the server sided project it won't find it since it looks in a different folder.

How should I proceed with this? Am I being clear enough?

Thanks, Eton B.

+1  A: 

Why not just add the same setting to the server-side project? Am I missing something?

Wil P
Yes, I probably didn't explain myself well enough.The XML file contains data that gets turned into DTOs to get transferred into a DB. This XML file is located on the client machine. If I add the XMLFileName key to the server-side project's appSettings, for example with value "File.xml", it tries to read the file somewhere inside that project's folders instead of the client-side one.
Eton B.
@Eton B: so you want your server to be able to reach into the client's harddisk and read the file from there???
marc_s
Not quite, I want the server to be able to call a client's method without using the server's appSettings. At the moment, if I call the method through the server and I look at ConfigurationManager, it shows that it's reading the web.config settings as opposed to the app.config in the client. I assume this is because the method is being called from the server.
Eton B.
A: 

I may not understand the problem completely, but it sounds like you have two different applications (client and server) using the same method (e.g. GetXmlFile()) to retrieve the same file (File.xml). If that's the case, then you probably need to have the XML file on a shared drive that can be accessed by a UNC path (e.g. `\myclient\XMLFiles\File.xml').

If that is the scenario, can you change the method GetXmlFile() to use a UNC path to access the file, and to store a UNC path and file name in your appSettings?

If I'm mis-understanding the situation, please let me know and I'll update my answer accordingly.

Hope this helps.

David Hoerster
I want the server to be able to call a client's method without using the server's appSettings. At the moment, if I call the method through the server and I look at ConfigurationManager, it shows that it's reading the web.config settings as opposed to the app.config in the client. I assume this is because the method is being called from the server.Do you think that's how I should approach this problem?
Eton B.
The web app is using the web.config settings because the web app uses web.config as it's starting point for configuration settings (by default). I think if you want both the client and the server to read the same file, you should abstract the method that reads the file out of the client code, add it to a third project (.DLL class library), include that project in both the client and server projects, and let each process (client and server) determine where the XML file is located based upon their respective appSettings or web.config configuration settings.
David Hoerster
I assumed that when control was passed to the client, its appSettings would apply. Now I know assuming is never a good idea.. the bad way. I've skipped this task for now as it seems too daunting for my newbie developing skills. What you say makes sense though so I will mark it as my answer. Thanks!
Eton B.