I am attempting to implement a configless setup, but have not been successful. I have read through all relevant forum posts, and have quadruple-checked my code to see if I can find the issue, but to no avail.
I am running
- EntitySpaces 2007.1.1210.0
- MyGeneration 1.3.0.3
- VS 2008
- IIS7
- ASP.Net 2.0
- SQL Server 2005.
Relevant code from Global.asax:
Code:
1 Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
2
3 ' // --- create connection
4 Dim conn As EntitySpaces.Interfaces.esConnectionElement = New EntitySpaces.Interfaces.esConnectionElement
5 conn.Name = "esDefault"
6
7 ' // --- This connection string would normally be populated at runtime...
8 ' // --- hardcoded for testing
9 conn.ConnectionString = "Data Source=mdsandiego; Initial Catalog=CMS; User ID=xxxx; Password=xxxx"
10
11 conn.Provider = "EntitySpaces.SQLClientProvider"
12 conn.ProviderClass = "DataProvider"
13 conn.SqlAccessType = EntitySpaces.Interfaces.esSqlAccessType.DynamicSQL
14 conn.ProviderMetadataKey = "esDefault"
15 conn.DatabaseVersion = "2005"
16
17 ' // --- Assign the Default Connection ---
18 EntitySpaces.Interfaces.esConfigSettings.ConnectionInfo.Connections.Add(conn)
19 EntitySpaces.Interfaces.esConfigSettings.ConnectionInfo.Default = "esDefault"
20
21 ' // --- Assign the Factory ---
22 esProviderFactory.Factory = New EntitySpaces.LoaderMT.esDataProviderFactory()
23 End Sub
Code from Test.aspx.vb
Code:
1 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
2 Dim oEdition As New BusinessObjects.ScEditions
3
4 ' // This block of code grabs the connection string from es and performs the
5 ' // database lookup without using es. This code succeeds.
6 Dim cn As New SqlConnection(oEdition.es.Connection.ConnectionString)
7 cn.Open()
8 Dim cmd As New SqlCommand("select * from scEditions where EditionID=1", cn)
9 Dim dr As SqlDataReader = cmd.ExecuteReader
10 While dr.Read
11 Response.Write(dr("EditionName") & "<HR>")
12 End While
13 dr.Close()
14 cn.Close()
15 dr = Nothing
16 cmd = Nothing
17 cn = Nothing
18
19 ' // error occurs here
20 oEdition.LoadByPrimaryKey(1)
21 Response.Write(oEdition.EditionName & "<HR>")
22
23 ' // if you comment out the above and do the thing without using primary key,
24 ' // you still get the same result
25 oEdition.Query.Where(oEdition.Query.EditionID = 1)
26 oEdition.Query.Load()
27 Response.Write(oEdition.EditionName & "<HR>")
28 End Sub
The error:
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 138: query.Where(query.EditionID.Equal(editionID))
Line 139:
Line 140: return query.Load()
Line 141:
Line 142: End Function |
Source File: D:\Webfolders\mydistrict.net_Admin\App_Code\EntitySpaces\Generated\ScEditions.vb Line: 140
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
EntitySpaces.Interfaces.esDataProvider.esLoadDataTable(esDataRequest request, esProviderSignature sig) +36
EntitySpaces.Interfaces.esDynamicQuery.Load() +511
BusinessObjects.esScEditions.LoadByPrimaryKeyDynamic(Int32 editionID) in D:\Webfolders\mydistrict.net_Admin\App_Code\EntitySpaces\Generated\ScEditions.vb:140
BusinessObjects.esScEditions.LoadByPrimaryKey(Int32 editionID) in D:\Webfolders\mydistrict.net_Admin\App_Code\EntitySpaces\Generated\ScEditions.vb:109
EntitySpaces_test.Page_Load(Object sender, EventArgs e) in D:\Webfolders\mydistrict.net_Admin\entityspaces\test.aspx.vb:15
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Adapters.ControlAdapter.OnLoad(EventArgs e) +12
System.Web.UI.Control.LoadRecursive() +2117945
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
|
Other applications using the same connection string (including MyGeneration and the main web application) function flawlessly.
Is there any way to get additional error information about what caused the statement to fail? Ideally, I'd like to see the exact error message received by the es object when it attempts to gain the connection and load the data. Is it possible to grab the SQL statement just before it's being executed to see if there's a problem there?
Do you see any other obvious errors in my implementation?
Thanks,
Rob Hudson
MyDistrict.Net
There are 10 kinds of people in the world... Those who understand binary, and those who don't.