ResourceManager.GetObject cannot get byte()

  • Thread starter Thread starter Gavin
  • Start date Start date
G

Gavin

Hi

I have created a resource file and have embedded strings
and bitmaps which I can retrieve without problem.
However, if I add a byte() object it fails with the
following msg:

"An unhandled exception of
type 'System.NotSupportedException' occurred in
mscorlib.dll

Additional information: System.Byte[]"

The code I used:

Dim RM As Resources.ResourceManager =
Resources.ResourceManager.CreateFileBasedResourceManager
(filename, ".", Nothing)

Dim b() As Byte = DirectCast(RM.GetObject("data.dat"),
Byte())

The code works without a problem if I run it on Windows
but fails on .NET CF?

Help

Gavin
 
I suggest you look at the .NET documentation for 'NotSupportedException'
and download the list of implemented and unimplemented feature on CF which
is ....
uh..... somewhere there is a link but I lost it ...
 
The resource manager in CF does not support generic byte streams. A simple
workaround is to edit your ResX file replacing the "System.Byte[]" with
"System.String". Since ResX stores byte streams as base64-encoded data, the
resulting resource will be still valid.

On CF side instead of casting GetObject() to Byte(), cast it to String. Then
use Convert.FromBase64String() to retrieve your byte array
 
Thanks Alex, got it to work now. I didn't know byte() is
not supported by GetObject!

Regards

Gavin
 
Lloyd, are you referring to the "Microsoft® .NET Compact Framework API
Documentation"? If so you can find it here:
http://msdn.microsoft.com/mobility/downloads/updates/default.aspx

cheers jonathan

--
Jonathan Wells
Product Manager
..NET Compact Framework
http://msdn.com/mobility

This posting is provided “AS IS” with no warranties, and confers no rights.

Lloyd Dupont said:
I suggest you look at the .NET documentation for 'NotSupportedException'
and download the list of implemented and unimplemented feature on CF which
is ....
uh..... somewhere there is a link but I lost it ...


Gavin said:
Hi

I have created a resource file and have embedded strings
and bitmaps which I can retrieve without problem.
However, if I add a byte() object it fails with the
following msg:

"An unhandled exception of
type 'System.NotSupportedException' occurred in
mscorlib.dll

Additional information: System.Byte[]"

The code I used:

Dim RM As Resources.ResourceManager =
Resources.ResourceManager.CreateFileBasedResourceManager
(filename, ".", Nothing)

Dim b() As Byte = DirectCast(RM.GetObject("data.dat"),
Byte())

The code works without a problem if I run it on Windows
but fails on .NET CF?

Help

Gavin
 
Back
Top