Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Mobile Development
  3. Mobile
  4. [SOLVED]Embedding large amount of binary data as byte arrays causes TypeLoadException [modified]

[SOLVED]Embedding large amount of binary data as byte arrays causes TypeLoadException [modified]

Scheduled Pinned Locked Moved Mobile
hardwaredata-structuresquestion
2 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    joelwms
    wrote on last edited by
    #1

    I am writing an app for Pocket PC that must concatenate several small wave files and play the result (text-to-speech). Loading the files from disk before concatenating them is too slow, so I decided to embed them by generating a class that includes each wave file as a byte array.

    static byte[] aa_aa = {80, 100, 200, ...};

    I assumed that this would make accessing them much quicker. It works fine if there are only a few, but when I have all 6 megs of them embedded in the class, when the app gets to the point of accessing one of these, I get a TypeLoadException. So I thought maybe it was because they were all declared static and it was trying to load all of them. So I rewrote it so that each byte array was in it's own class.

    public class aa_aa
    {
    public byte[] bytes;
    public void aa_aa()
    {
    bytes = {80, 100, 200, ...};
    }
    }

    This way the byte arrays should only be instantiated when there is a new object of that class. Unfortunately, I am still getting the TypeLoadException whenever this class is used. Does anyone have any ideas of what I can do to get around this?

    modified on Thursday, October 15, 2009 8:15 PM

    J 1 Reply Last reply
    0
    • J joelwms

      I am writing an app for Pocket PC that must concatenate several small wave files and play the result (text-to-speech). Loading the files from disk before concatenating them is too slow, so I decided to embed them by generating a class that includes each wave file as a byte array.

      static byte[] aa_aa = {80, 100, 200, ...};

      I assumed that this would make accessing them much quicker. It works fine if there are only a few, but when I have all 6 megs of them embedded in the class, when the app gets to the point of accessing one of these, I get a TypeLoadException. So I thought maybe it was because they were all declared static and it was trying to load all of them. So I rewrote it so that each byte array was in it's own class.

      public class aa_aa
      {
      public byte[] bytes;
      public void aa_aa()
      {
      bytes = {80, 100, 200, ...};
      }
      }

      This way the byte arrays should only be instantiated when there is a new object of that class. Unfortunately, I am still getting the TypeLoadException whenever this class is used. Does anyone have any ideas of what I can do to get around this?

      modified on Thursday, October 15, 2009 8:15 PM

      J Offline
      J Offline
      joelwms
      wrote on last edited by
      #2

      I solved it. The problem wasn't with anything I posted here. It was in the code to pull out the resource. Basically, I had a switch statement to get an object from a string.

      switch (resource)
      {
      case "aa-aa":
      return new aa_aa().bytes;
      case "aa-ae":
      return new aa_ae().bytes;
      ....
      }

      The problem was that there were too many case statements. I didn't know that was possible. I changed it to use if statements instead it works fine.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups