[Mono-dev] System.Resources.ResourceManager:ReleaseAllResources() throws System.InvalidCastException
Arnhoffer Károly
karnhoffer at ecron.hu
Tue Jan 17 05:55:17 EST 2006
Hi,
Any time I call System.Resources.ResourceManager:ReleaseAllResources() method I get System.InvalidCastException.
For example I load texts from aspx.resx files to aspx pages with the function below. The text loads successfully, but becouse of the lobjRM.ReleaseAllResources() call it does not return the value.
Is the lobjRM.ReleaseAllResources() call needed anyway? I found in the .Net docs that "this method will shrink the working set in a running application". That is only why I use it.
Public Function LoadRes(ByVal tstrResource As String, ByVal tstrResID As String) As String
Dim lstrModul As String
Dim lobjAssembly As System.Reflection.Assembly
Dim lobjRM As System.Resources.ResourceManager
Dim lstrText As String
Try
If tstrResource.IndexOf("."c) >= 0 Then
'Ha a modulnv benne van az tadott resource nvben, akkor onnan veszi ki:
lstrModul = tstrResource.Substring(0, tstrResource.IndexOf("."c))
End If
lobjAssembly = System.Reflection.Assembly.LoadWithPartialName(lstrModul)
If lobjAssembly Is Nothing Then Return Nothing
Try
lobjRM = New System.Resources.ResourceManager(tstrResource, lobjAssembly)
lstrText = lobjRM.GetString(tstrResID)
Catch
Finally
If Not lobjRM Is Nothing Then lobjRM.ReleaseAllResources()
End Try
Return lstrText
Catch ex As Exception
Response.Write(ex.GetType().ToString & "<br />" & ex.StackTrace)
End Try
Thanks!
Károly
More information about the Mono-devel-list
mailing list