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
C:\Inetpub\wwwroot\FPA\www\WebModules\Requests\RequestCreate.aspx.vb:line
231
at KMG.WebModules.Requests.Web.RequestCreate.Page_Load(Object sender,
EventArgs e) in
C:\Inetpub\wwwroot\FPA\www\WebModules\Requests\RequestCreate.aspx.vb:line
110
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"),
ModuleSettings)
If data Is Nothing Then
Dim serializer As New XmlSerializer(GetType(ModuleSettings))
Try
Dim fileName As String
HttpContext.Current.Server.MapPath(GetSettingsFile())
' 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)
fileStream.Close()
context.Cache.Insert("Requests_SettingsFile", data, New
CacheDependency(fileName))
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.
C.