Home All Groups Group Topic Archive Search About

Exception trying to retrieve from My.Resources

Author
13 Feb 2007 4:44 PM
Barry Gilbert
In a Property Set statement, I'm trying to retrieve a value from My.Resources
like this:

    Public Property TimeEnd() As DateTime

<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
        Get
            Return _timeEnd.Date
        End Get

<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
        Set(ByVal value As DateTime)
            CanWriteProperty(True)
            If Not _timeEnd.Equals(value) Then
                _timeEnd.Date = DateAdd(DateInterval.Year,
CInt(My.Resources.SqlMinYear), value.TimeOfDay)
            End If
        End Set

The purpose of SqlMinYear is to allow the UI to receive a time only and to
store it by appending SQL Server's min date. However, when I try to retrieve
this Resources string, I get this error:

"'My.Resources.SqlMinYear' is not declared or the module containing it is
not loaded in the debugging session."

I get the same thing if I try to get the value in the immediate window.

Any ideas?

Author
13 Feb 2007 4:49 PM
Barry Gilbert
Never mind. It turns out that if I use Console.WriteLine, it does correctly
display the value. I don't understand why, but statements in the immediate
window don't always jive with what is returned by Console.Write.

Also, sorry for the triple post; it's some bug in my Firefox installation.

Barry

Show quote
"Barry Gilbert" wrote:

> In a Property Set statement, I'm trying to retrieve a value from My.Resources
> like this:
>
>     Public Property TimeEnd() As DateTime
>        
> <System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
>         Get
>             Return _timeEnd.Date
>         End Get
>        
> <System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
>         Set(ByVal value As DateTime)
>             CanWriteProperty(True)
>             If Not _timeEnd.Equals(value) Then
>                 _timeEnd.Date = DateAdd(DateInterval.Year,
> CInt(My.Resources.SqlMinYear), value.TimeOfDay)
>             End If
>         End Set
>
> The purpose of SqlMinYear is to allow the UI to receive a time only and to
> store it by appending SQL Server's min date. However, when I try to retrieve
> this Resources string, I get this error:
>
> "'My.Resources.SqlMinYear' is not declared or the module containing it is
> not loaded in the debugging session."
>
> I get the same thing if I try to get the value in the immediate window.
>
> Any ideas?

AddThis Social Bookmark Button