Error: The DataSourceKey [] is not defined.
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Error: The DataSourceKey [] is not defined.Expand / Collapse
Author
Message
Posted 04/16/2008 7:25:01 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 10:56:28 AM
Posts: 53, Visits: 211
I'm getting the error (below) when run on my production website.  The app runs fine on my development machine.  As a result, am stumped as to how to debug it.

The SaeWeb project is referencing my SaeBOL project for business objects.

On my dev machine, I can see that my Global.asax.vb is creating a DataSource correctly with "" key and correct connectionstring:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
DataLayer.DataSources.Add(New SqlDataSourceItem("", _
"Data Source=tcp:sql2k513.discountasp.net;Initial Catalog=SQL2005_386891_sae; User ID=*****; Password=*****"))
End Sub

My SchoolBO has a "" as its DataSourceKey.

Much to my amazement, when run on my development machine this web page is actually connecting the the production SQL database at the web host.

Not sure what might be missing in the installed version on the website.  Any help much appreciated. 

-- Larry  (using VS2008 and .NET 3.5 build target)

Server Error in '/' Application.
--------------------------------------------------------------------------------

The DataSourceKey [] is not defined.
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: MicroFour.StrataFrame.Data.DataLayerException: The DataSourceKey [] is not defined.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin
and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[DataLayerException: The DataSourceKey [] is not defined.]
   MicroFour.StrataFrame.Data.DataLayer.Create(BusinessLayer BusinessObject, ISynchronizeInvoke SyncObject, Boolean CheckDesignTime) +271
   MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +79

[DataLayerException: An error occurred while creating a new DataLayer for the business object.]
   MicroFour.StrataFrame.Business.BusinessLayer.get__DataLayer() +149
   MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement) +15
   SaeBOL.SchoolBO.FillAll() +13
   SaeWeb.SchoolForm.Page_Load(Object sender, EventArgs e) +46
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

Post #15711
Posted 04/16/2008 8:03:12 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 8:47:41 AM
Posts: 4,104, Visits: 4,175
The issue is actually straight forward in the sense of the error.  The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.  You might write to a log file or something when the connection is created to ensure that the data source is being added.  The hosted environment may also be resetting the application pool, sessions, or something along those which is loosing instantiated objects.
Post #15715
Posted 04/17/2008 12:00:08 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 10:56:28 AM
Posts: 53, Visits: 211
The hosted environment doesn't have the DataSources collection populated when the BO is referencing it, thus it throws the error.

Could you explain how you came up with this?  The DataSource collection isn't mentioned in the error message.  How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?

You might write to a log file or something when the connection is created to ensure that the data source is being added.

Again, I need more information.  Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file if the datasource was not added?  Assuming it succeeded, are you saying check it again when my SchoolBO.FillAll() fires because something in the web hosting environment could have deleted it in the interim? 

Thanks,

Larry

Post #15731
Posted 04/17/2008 12:49:57 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 8:47:41 AM
Posts: 4,104, Visits: 4,175
Could you explain how you came up with this?  The DataSource collection isn't mentioned in the error message.  How did you go from "DataSourceKey [] is not defined" to "missing DataSource item"?

Well, a data source key is comes from the DataSourcesCollection.  The key means absolutely nothing if it doesn't exist in the data sources collection.  This is set in the Application_Start in the global.asax when  you add your data source item to the data source collection.

That's how I went there.

Wouldn't the DataLayer.DataSources.Add() fail in the Global.asax file if the datasource was not added? 

That IS the data source collection.  DataSources is a colleciton of data source items.

Assuming it succeeded, are you saying check it again when my SchoolBO.FillAll() fires because something in the web hosting environment could have deleted it in the interim? 

Yup.  When the SchoolBO.FillAll() happens it uses its data source key to pull from the data source collection when the DAL is going to fetch the data.  By this time the data source item within the collection apparently is not there.  So the hosting environment could be doing something that is forcing the shared classes to be GC'ed or shut down and then recreated without going through the Application_Start.  Do you even know if the Application_Start is evern happening on the hosted site?  That is the first thing I would check.

Post #15733
Posted 04/17/2008 2:48:40 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 10:56:28 AM
Posts: 53, Visits: 211
Okay.  Thanks for the clarification. 

I understand the DataLayer.DataSources.Add() is where the item is created in the collection.  I meant that I would have expected it to return some sort of failure warning / exception if it had not created the DataSourceItem.  It never occurred to me that a web app could run without the app_start firing

Moving from the self-contained world of VFP to this disconnected / remote environment is tough.  There are layers upon layers of things that can go wrong.  Sometimes it feels like visiting a foreign country where you miss things that are obvious to the local residents because you don't know the context of the culture / language.  Bet you never considered yourself a "tour guide".

Again, your support is much appreciated.   I'm doing a lot of reading and troubleshooting before resorting to your guidance.

-- Larry

Post #15740
Posted 04/17/2008 3:58:45 PM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 10:56:28 AM
Posts: 53, Visits: 211
Trent,

Good call on the Global.asax file.  For whatever reason, probably operator error  ,sending up a fresh version to the website solved it.  Commencing headbanging...

Larry

Post #15743
Posted 04/17/2008 4:23:01 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 8:47:41 AM
Posts: 4,104, Visits: 4,175
Yeah...I figured that was the case...glad you got it going!
Post #15747
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 10:01am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.062. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.