none
new DataClassesDataContext : Type is not defined BC30002 | System.Data.Linq present in .config file RRS feed

  • Question

  • Hello! Happy spooky Friday the 13th! 

    I was given some older code and I am tasked with changing some things; I am somewhat familiar with Visual Studio Basic but when it comes to a project/environment of this magnitude, I'm a bit lost. A lot of the code is legacy and I have been working out compatibility kinks in order to get the project to deploy as a test website that will allow me to see the changes I make. The code requires that I use SQL 2008 R2; the 'practice' database file exists within the project and I have attached it to my local SQL server in order to have access to the database in VS. 

    I have been getting the Type 'DataClassesDataContext' is not defined error every time I attempt to compile the project; I include the System.Data.Linq assembly in the config file, as well as the namespace. I am also importing the System.Linq / System.Data / and System.Data.Linq on the page that is giving me the error:

    <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>...

    ...<add namespace="System.Data.Linq"/>

    The file I am having issues with resides inside of the App_Code directory. The block that is giving me issues is as follows: line 9

    <WebMethod()>
        Public Function GetLocationList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
    
            Dim returnList As New List(Of String)
    
            Try
    
                Dim cs As String = ConfigurationManager.ConnectionStrings("TrackingConnectionString").ConnectionString
                Dim context As DataClassesDataContext = New DataClassesDataContext(cs)
                context.Connection.Open()

    Please forgive my ignorance to the issue; I've tried to remedy this issue over the past few days, but I don't think I'm properly understanding the issue I am currently having. I think it is a Linq to SQL issue and I don't mean to pollute the forum space if I am incorrect! I would appreciate any and all advice; even just an appropriate search term to point me in the right direction. 

    Thank you for your time and patience! 

    :)


    :)

    Friday, October 13, 2017 4:29 PM

Answers

  • Hi,

    After reading your description, I suggest you try to recreate the DataClassesDataContext.

    Delete the DataClassesDataContext dbml then follow the steps to create add LINQ to SQL Classes to a Project:

    1. From within a Visual Basic or C# application, on the Project menu, click Add New Item.

       2. Click the LINQ to SQL Classes template.

       3. Either provide an alternative name or keep the default name of DataClasses1.dbml.

       4. Click Add. The .dbml file is added to the project and the O/R Designer opens.

    https://msdn.microsoft.com/en-us/library/bb384470.aspx

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, October 16, 2017 5:41 AM

All replies

  • Okay! Found the first issue! solved this to some degree! 
    It looks like the DataClasses.dbml was referencing the previous users local database, I changed the database name to reflect the changes

    <?xml version="1.0" encoding="utf-8"?><Database Name=".\SQLEXPRESS" Class="DataClassesDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">

    And now I am getting the errors 'Location" is not a memeber of 'DataClassesDataContext' / 'Project' is not a member of 'DataClassesDataContext':BC30456
    Are these members to be added to the DataClasses.dbml.layout? or added to the Table in the DataClasses.dbml file?


    :)


    Friday, October 13, 2017 5:11 PM
  • I'm starting to think that the DB file that I was given is incomplete or incorrect; 

    :)

    Friday, October 13, 2017 6:05 PM
  • Hi,

    After reading your description, I suggest you try to recreate the DataClassesDataContext.

    Delete the DataClassesDataContext dbml then follow the steps to create add LINQ to SQL Classes to a Project:

    1. From within a Visual Basic or C# application, on the Project menu, click Add New Item.

       2. Click the LINQ to SQL Classes template.

       3. Either provide an alternative name or keep the default name of DataClasses1.dbml.

       4. Click Add. The .dbml file is added to the project and the O/R Designer opens.

    https://msdn.microsoft.com/en-us/library/bb384470.aspx

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, October 16, 2017 5:41 AM
  • Hiya Bob! Thank you for the response :)

    Your solution worked like a charm. I exported the data from the database contained in the project into a new database that I created that matched the name of the database that was referenced in the .sql file and ran the .sql file on the new database in order to inject the data and queries that it contained. I then created a new DataClasses.dbml LINQ to SQL file within the project as per your / msdn instructions. I pulled the corresponding tables into the OR manager and changed the name of the title of the references in the DataClasses.designer.vb file to match the table names that I pulled into the OR manager and the site compiled; I now have a working environment that I can fiddle with.

    I really appreciate you taking the time to respond, thank you so much for your time and expertise! 



    :)

    Monday, October 16, 2017 5:57 PM