Console app works, but WPF app doesn't.
Console app works, but WPF app doesn't.
Hi,
Don't know if this is related to dotConnect for Oracle. But that's what I used to create the entity model. Here's the description (sorry for its length. But I can assure you that the whole thing is very simple test project).
The situation is that two projects in the solution, both using the same entity framework class library, one (console app) can create the context (ObjectContext subclass), the other one (wpf app) can't. Both has exactly the same app.config to connect to Oracle database.
Here's what I did:
1. Create a class library:
I added a model file (the edmx file) that I created for other project (by using 'Add Existing Item' from the project). VS 2008 automatically generated the cs file and add references right after I added the file. Perfect.
2. Create a Console App:
I added the reference to the class library above. And in Main() I only have this:
static void Main(string[] args)
{
PlanEntryEntities context = new PlanEntryEntities();
List plans = context.ACIPE_PLANS.OrderBy(p => p.ACIPE_VENDOR.VENDOR_DESC).ToList();
plans.ForEach(p => Console.WriteLine("{0}", p.PLAN_DESC));
}
Worked fine.
3. Created a WPF App
There is nothing in the Window xaml file, except an handler for Loaded event.
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
PlanEntryEntities context = new PlanEntryEntities();
List plans = context.ACIPE_PLANS.OrderBy(p => p.ACIPE_VENDOR.VENDOR_DESC).ToList();
}
}
When I ran this WPF app, it died on the first line:
PlanEntryEntities context = new PlanEntryEntities();
With this error message: "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
the configuration file is the same for both:
I checked and rechecked. I just can't see why it worked one way (console) but not working the other way (wpf). Does anyone has any idea? Thank You!
We have sent you a simple test class library with console and WPF sample applications created in the way you have described.
Everything worked OK.
Maybe, this link will help:
http://social.msdn.microsoft.com/Forums ... 146d8e1a68
Everything worked OK.
Maybe, this link will help:
http://social.msdn.microsoft.com/Forums ... 146d8e1a68
Hi, Andrey
Thanks a lot. It did solve the problem. It turns out that the name of the connection string ARE different. I thought I did the copy and paste at least 3 times between console app and wpf app. Apparently, I still managed to produce this error. Thank you very much for trying to solve my problem.
Vincent
Thanks a lot. It did solve the problem. It turns out that the name of the connection string ARE different. I thought I did the copy and paste at least 3 times between console app and wpf app. Apparently, I still managed to produce this error. Thank you very much for trying to solve my problem.
Vincent