Posted by: Mohamed | 26/02/2011

Referencing to App.Config file in a different project

While I was conducting a simple test application using ADO.NET Entity Model Framework, I found out that I get always runtime errors because the UI project (which is a windows form project) cannot get an instance of an object from a class library (this class library is where the Entity Model resides!).

The only solution which I could find for this problem is to copy the App.Config file from the ClassLibrary, to the UI Project. Of course, I cannot see this as an efficient way of solving this problem in case the project gets larger. After Googling around and couple StackOverFlow posts, there was a nice solution to it ;). We could just leave a shortcut of the App.Config in the UI Project, and here are the steps (I’m using Visual Studio 2010 BTW):

  1. In the project which you want to paste that App.Config file (in my case was UI Project), RightClick -> Add Existing Item.
  2. Navigate to the original App.Config file (in my case it was the ClassLibrary) and BEFORE you click add (or double click on the file), click on the arrow in the “Add” button, and choose “Add As Link”

That’s it :), now you can change the App.Config once, instead of changing several copies of them ;).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Categories

%d bloggers like this: