Good morning,

I get an error “CLR_E_OUT_OF_RANGE”. I deleted the code but it gave me the error is still present, do you have any idea?

Thanks you

Can you please show us your code?

Hello Thibault

This is a wrong category for your topic, “native programming” is a RLP focused one.

How big are your binaries and resources? That error will be given if there’s not enough room on te device to deploy.

Hello everyone,

May a moderator can move this topic in the appropriate category?

The code is about 200800 bytes. As soon as we add a new line, (as for example a debug.print statement) VS shows CLR_E_OUT_OF_RANGE

There is limit on the assembly size on NETMF. You will need to split your code in multiple assemblies. I think it was 300Kbytes?

Ok this can be the reason of the issue:

Is there a trick to know that we’re getting closed from the limit?
I’ve never created multiple assemblies. May you explain to me or give an index on how to do that?

@ leforban - I assume Gus means to create Class Libraries in your project and move code into them to create the new assemblies.

Like this…

1 Like

Hmmm… Does this limit include resources included in the assembly? This may be the cause of an issue I’m having…

Yes, NETMF heap allocator has limits. You can’t have very large object of any sort, arrays, assemblies, resources!

What does large means? As soon as a limit exists, knowing the exact boundaries is good. For now all seems implicit.

So, if you want to include a resources that exceeds 300k (an image maybe…) is there any other option than to include an SD card and load it at runtime?

That would depend on the device you are running. Each has different total amounts available.

You can make a call to the GC and it will let you know how much you have free.

Something like:

Debug.Print("Memory: " + Microsoft.SPOT.Debug.GC(false).ToString()); 

Soon there’ll be some external flash memory options.

You can have large resources but you can only have a limited size buffer to take the resource in. 4.2 lets you read part of your resource.

Ok thanks guys, the problem has been soved by using library class.

Hello all,
I have the same issue CLR_E_OUT_OF_RANGE, when I just add some bytes in my code.
So I would like to use a library class, as suggested (and done successfully by leforban) and put all my ressources in this new class. But I don’t know how to access those resource in this library from the other class. Because the resources that are automatically created by Visual Studio are internal and cannot be accessed from a different assembly. I have changed internal to public, but then I get " type or namespace name could not be found " errors in Resources.Designer.cs :

Le type ou le nom d'espace de noms 'CodeDom' n'existe pas dans l'espace de noms 'System' (une référence d'assembly est-elle manquante ?)	
Le type ou le nom d'espace de noms 'CompilerGeneratedAttribute' n'existe pas dans l'espace de noms 'System.Runtime.CompilerServices'
Le type ou le nom d'espace de noms 'CompilerGeneratedAttributeAttribute' n'existe pas dans l'espace de noms 'System.Runtime.CompilerServices' 
Le type ou le nom d'espace de noms 'CodeAnalysis' n'existe pas dans l'espace de noms 'System.Diagnostics' 

Any idea / workaround?

I finally suceed to access to my ressources that are in a second project/namespace.
For that I edited manually the Resources.Designer.cs file , replacing all “internal” to “public” in order to expose the Methods. It is a really unproper, but it allows to access ressources in this way from my main project :

bitmap = namespace_Ressources.Resources.GetBitmap(namespace_Ressources.Resources.BitmapResources.Anim01);

Unfortunately, it does not fix my CLR_E_OUT_OF_RANGE issue. I don’t really understand where is the limitation: what is curious is that this exemple will work

//...lot of variables before
static string sTest = "0123456789012345678901234567890123456789";

this other works too:

//...lot of variables before
static int iTest1 = 0;

but not this :

//...lot of variables before
static int iTest1 = 0;
static int iTest2 = 0; 

I have a lot of static variables (more than 200 from different types ) maybe a limitation around that?

I forgot to say that I am on EMX module. here is the final deployment log :

Total: (21032 RAM - 1075648 ROM - 93644 METADATA)
   AssemblyRef    =      272 bytes (      68 elements)
   TypeRef        =     1940 bytes (     485 elements)
   FieldRef       =      188 bytes (      47 elements)
   MethodRef      =     2636 bytes (     659 elements)
   TypeDef        =     4464 bytes (     558 elements)
   FieldDef       =     2796 bytes (    1389 elements)
   MethodDef      =     5744 bytes (    2865 elements)
   DebuggingInfo  =     2892 bytes
   Attributes      =       48 bytes (       6 elements)
   TypeSpec        =       56 bytes (      14 elements)
   Resources Files =      144 bytes (       6 elements)
   Resources       =      816 bytes (     102 elements)
   Resources Data  =   849185 bytes
   Strings         =    39349 bytes
   Signatures      =    12852 bytes
   ByteCode        =    89669 bytes

Thank you for any help.

It is made private for a reason.

You can’t access resources in different project/assembly like that. All it does is that it is trying to get a resource in your local assembly using an ID from a different assembly.

What are you trying to do?