I ran into a similar problem a long while back with the VB6 Printer object.
'With Printer', followed by '.something=whatever' failed, but
Printer.something worked. I don't recall the details. After much chasing my
tail, I fully qualified all references to Printer.
So... Maybe something is taking precedence over your 'with' statement, as I
am guessing appened to me in VB6. The name of your variable, 'data', is a
name likely to be used in other contexts, and maybe one of those contexts is
defeating the With construct.
To determine this, try:
With _state
.SomeObscureName = whatever
End with
where SomeObscureName is defined in _state and is a name that is unlikely to
be used anywhere else by anybody. If that works, then your result will be
similar to my VB6 result. In my 'with printer' construct, some things worked
and some things didn't. In your case, 'with _state', we know only that .data
does not work. Maybe it does work with a name other than '.data'. If it
does work, it would be interesting to see what the IL is.
"guy" wrote:
VB.NET2005 WinXP SP2
I have some code that looks like:-
with _state
...
.data =GetData()
...
end with
where .data is a DataTable
this code has worked fine for 2 weeks
now however although GetData returns 15 rows .data always has rows.count =0
If I change the code to:-
with _state
...
_state.data =GetData()
...
end with
i.e. ignore the With, the code works again
See also this:-
with _state
...
dim dt as DataTable =GetData()
.data=dt 'this fails
_state.data=dt 'this succeeds
...
end with
any Ideas?
Guy