Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2011, 08:11 AM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default Ch14 Linq and EDO.net - ERROR

I am working on Ch14 Linq and EDO.net

I have completed the first Try it Out but have the following error when I view page in a browser:


Code:
Server Error in '/WebSite1' Application.
--------------------------------------------------------------------------------

The specified metadata path is not valid. A valid path must be either an existing directory, an existing file with extension '.csdl', '.ssdl', or '.msl', or a URI that identifies an embedded resource. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.MetadataException: The specified metadata path is not valid. A valid path must be either an existing directory, an existing file with extension '.csdl', '.ssdl', or '.msl', or a URI that identifies an embedded resource.

Source Error: 

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
   <system.web>
       <compilation debug="true"/>
   </system.web>
</configuration>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario
And my code behind is this:
Code:
Imports DatabaseModel
Partial Class All
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Using myEntities As New ClientManagerEntities()
            Dim allnames = From name In myEntities.names
                             Where name.Active = True
                             Order By name.Age Descending
                             Select name
            GridView1.DataSource = allnames
            GridView1.DataBind()
        End Using
    End Sub
End Class
What's wrong?
 
Old November 28th, 2011, 08:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Looks like your EDMX is not OK. How and where did you add it to the project? (Which folder and so on). And can you post the code for the associated connection string in web.config?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
leeWozyWarren (November 29th, 2011)
 
Old November 28th, 2011, 08:36 AM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

I followed the try it out in CH14. I created a App_Code folder in the usual way then right click to add a new file, and chose ADO.NET Entity Data Model then followed the outline in the book substituting the names for my own tables. Code here for the string:


Code:
    <add name="ClientManagerEntities" connectionString="metadata=res://*/Ap:/p_Code.clientmanager.csdl|res/*/App_Code.clientmanager.ssdl|res://*/App_Code.clientmanager.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\Database.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 
Old November 28th, 2011, 09:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Don't know how it got there, but this doesn't look right to me:

//*/Ap:/p_Code.client

That should be App_Code....

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
leeWozyWarren (November 29th, 2011)
 
Old November 29th, 2011, 10:17 AM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

thanks Imar. All working now :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
New error in working LINQ code chroniclemaster1 ASP.NET 4 General Discussion 0 June 3rd, 2011 02:17 PM
linq in asp.net bhupesh ASP.NET 3.5 Basics 0 May 25th, 2011 02:26 AM
Ch14;get Class not register error with Code Example clay5050 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 5 December 23rd, 2009 07:17 AM
LINQ Error ? Chapter 13 workidoo BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 22nd, 2008 09:37 AM
Should I learn ado.net Or linq? chobo2 LINQ 2 January 4th, 2008 06:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.