Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NotSupportedException on static constructor?

10 views
Skip to first unread message

Alex Feinman

unread,
Apr 23, 2003, 2:45:46 AM4/23/03
to
It's definitely static array size. Reducing it I was able to get to the
point where it stopped failing. The interesting points:
1) Splitting array in two parts did not help, so it is not a single array
size.
2) With or without splitting initialization is done in a single subroutine.
The size of this routine decreases by about 15% after spliting array in 2
(because the code is generated differently). It does not seem to help
though, so the problem is not in the IL code size.
3) The same code runs fine on the desktop (without recompile) - there is
nothing wrong with the codegenerator.

I have to conclude that the problem must be with the execution engine (since
we were told at some point if memory serves me right, that IL is not
JIT-compiled on CF)

By the way - your array is not 255 string items, but 8x256 = 2048 string
items. When reduced to 1480, it works

Alex

"Oren Novotny" <o...@NOpo.SPcwru.AMedu> wrote in message
news:ugl8taUC...@TK2MSFTNGP10.phx.gbl...
> I am trying to create an OTP[1] client for PPC. I have custom MD4 and MD5
> implementations that are "pure" C# code, so that part is out of the way.
> The trouble is that one of the static member variables in the OTP class is
> causing a NotSupportedException to be thrown upon initialization.
>
> If I try to access a static function, I get it, or if I try to create a
> new
> instance of the class, I get it as well. I don't see what would be
> causing
> this; the only thing getting initialized is a fairly large array (well,
> only
> 255 string items).
>
> Any ideas?
>
> [1]: http://www.ietf.org/html.charters/otp-charter.html
>
> (This is my first post via the "Managed" mechanism of MSDN--I registered
> the
> spam alias, so if this isn't the place, please let me know).
>
> Thanks!
> --Oren
>
>
>

Oren Novotny

unread,
Apr 23, 2003, 6:52:14 AM4/23/03
to
Alex,

Thanks for looking into this (it was late last night so my math was a bit
off ;)). The question is, is what to do in the interim. The contents of
that array need to be in the program in that order since that's what is
defined by the spec.

Assuming that half of the items are three characters and the remaining are
four, and assuming 2 bytes per character, I get a total of 14K of memory.
So that's not even a particularly large item.

Would it help to stick all the items into an ArrayList? Would
static/instance make a difference (I ported a java version, so I didn't
bother mucking with the underlying structure/logic--I think they used it as
a static method just so that the array would only have to be in memory
once.)

I did notice that the executable worked on the desktop, so I was rather
surprised.

I look forward to finding a solution :)
--Oren

"Alex Feinman" <publi...@alexfeinman.com> wrote in message
news:#N1Q5PWC...@TK2MSFTNGP12.phx.gbl...

Jeremy Hance [MSFT]

unread,
Apr 23, 2003, 8:24:08 PM4/23/03
to
The important point to remember here is that your array initializer is
going to be jitted into a static constructor. In the Compact Framework, no
function is allowed to have jitted code in excess of 64K. Since each one
of your strings is a seperate object, it needs to be seperately
instantiated, and then added to your array. It is quite possible that your
jitted static constructor code is passing this 64K limit, and hence
throwing the NotSupportedException.

You might want to consider attempting to load these strings from a file, or
from an embedded resource. You could even, potentially, break the
instantiation of your array into several functions.

Loading the strings from a file or embedded resource would be cleaner, but
using multiple functions would likely be higher performance.

I hope this helps.

Jeremy Hance
NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Oren Novotny" <o...@NOpo.SPcwru.AMedu>
| References: <ugl8taUC...@TK2MSFTNGP10.phx.gbl>
<#N1Q5PWC...@TK2MSFTNGP12.phx.gbl>
| Subject: Re: NotSupportedException on static constructor?
| Date: Wed, 23 Apr 2003 06:52:14 -0400
| Lines: 80
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <OF4hnZYC...@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 97.37.171.66.subscriber.vzavenue.net 66.171.37.97
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:21370
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Oren Novotny

unread,
Apr 23, 2003, 9:21:38 PM4/23/03
to
That's basically what I wound up doing. I put the strings into a text file
that I embedded as a resource and then used a StreamReader to get them out
and into an ArrayList.

Would it be possible for the compiler to throw a warning in cases where the
JIT'd code would surpass those limitations? It would seem to be one of
those things that's easy to do by accident but hard to determine the cause
later.

--Oren

"Jeremy Hance [MSFT]" <jhanc...@online.microsoft.com> wrote in message
news:EK5lXffC...@cpmsftngxa06.phx.gbl...

Jeremy Hance [MSFT]

unread,
Apr 25, 2003, 6:19:00 PM4/25/03
to
The same compiler is used both for the full .NET Framework and the .NET
Compact Framework. The only differences are in the BCLs that your
application links against. Of course, this limit does not apply on the
Desktop Framework.

Jeremy Hance
NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Oren Novotny" <o...@NOpo.SPcwru.AMedu>
| References: <ugl8taUC...@TK2MSFTNGP10.phx.gbl>
<#N1Q5PWC...@TK2MSFTNGP12.phx.gbl>

<OF4hnZYC...@TK2MSFTNGP11.phx.gbl>
<EK5lXffC...@cpmsftngxa06.phx.gbl>


| Subject: Re: NotSupportedException on static constructor?

| Date: Wed, 23 Apr 2003 21:21:38 -0400
| Lines: 159


| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0

| Message-ID: <O6ROc$fCDHA...@TK2MSFTNGP12.phx.gbl>


| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 97.37.171.66.subscriber.vzavenue.net 66.171.37.97

| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:21494
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Oren Novotny

unread,
Apr 25, 2003, 11:00:11 PM4/25/03
to
Right... but perhaps when building a CF solution, after compiling, some
tool can JIT the binaries to check method sizes.

Maybe for Whidbey ;)

--Oren

"Jeremy Hance [MSFT]" <jhanc...@online.microsoft.com> wrote in message

news:$mmhxi3C...@cpmsftngxa06.phx.gbl...

0 new messages