views:

49

answers:

2

I am having a weird Situation with my DataConext. All My code is in C# I have a DLL project for my data access layer and business Layer which and Winforms project for my UI layer.

My Data access Layer's Namespace is xxx.Data this is where have my xxx.dbml I also have xxx.Data.BusinessObjects name space of course for my business object in that project

In my UI Layer I have these namespaces xxxApp(for Forms), xxxApp.Controls (For Controls)

I have lost scope of the DataContext, it was accessible now when I do a Rebuild Solution I sometimes get compile errors saying for example:

Error 34 'xxx.Data.xxxDataContext' does not contain a definition for 'SubmitChanges' and no extension method 'SubmitChanges' accepting a first argument of type 'xxx.Data.xxxDataContext' could be found (are you missing a using directive or an assembly reference?)

Also intelisense doesn't recognize the methods and table classes from my xxxDataContext anymore

I can access all object fine when I am in the DLL project but now in the Winforms project

this is very strange. If anyone can help me out I would be extremely grateful!

A: 

You might be missing some assembly references in you Windows Form project like in this post. Are you seeing any other error? like for instance:

"Error x The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.xxxx, Version=x.x.x.x, Culture=neutral, PublicKeyToken=...........

Try adding System.Data.Linq and System.Data.Entities if they are missing in your project references.

Cristian
Thats not it, I have both References in my projects.
greektreat
+3  A: 

Perhaps you have duplicated a .dbml file in your DLL and Winforms projects. If so, remove the unwanted file and the error should be fixed.

Steve Dignan
YES this was the cause! i must have copied the dbml file to the winform project by mistake with a drag and drop! thanks for the response! The reason it still compiles is because it the class behind the dbml file is a partial class so they both can exists.
greektreat