p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

aspdotnet_website_programming thread: Works locally but breaks on the server

Message #1 by "C. Holliday" <crholliday@h...> on Mon, 24 Mar 2003 22:45:49
I have a site that seems to be working fine on my local machine, but on 
the server it throws an error of the type:

System.InvalidCastException: Specified cast is not valid.

I believe it is breaking on the serialization of some config items.  The
stack reads:

   at KMG.WebModules.RequestManager.Configuration.ModuleConfig.GetSettings
   at KMG.WebModules.RequestManager.Business.Helper.GetTypes()
   at KMG.WebModules.Requests.Web.RequestCreate.BindData() in
   at KMG.WebModules.Requests.Web.RequestCreate.Page_Load(Object sender,
EventArgs e) in
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain()

GetSettings() looks like this:

Public Shared Function GetSettings() As ModuleSettings
Dim context As HttpContext = HttpContext.Current
Dim data As ModuleSettings = CType(context.Cache("Requests_SettingsFile"),
If data Is Nothing Then
Dim serializer As New XmlSerializer(GetType(ModuleSettings))
Dim fileName As String 
' Create a filestream to read the XML document
Dim fileStream As New fileStream(fileName, FileMode.Open)
' User the Deserialize method to retrieve the object state
data = CType(serializer.Deserialize(fileStream), ModuleSettings)
context.Cache.Insert("Requests_SettingsFile", data, New
Catch exc As System.IO.FileNotFoundException
' If the file is not found, return an empty class
data = New ModuleSettings()
End Try
End If
Return data
End Function

I would appreciate any help with this.


  Return to Index