New Posts New Posts RSS Feed: Encryption/Decryption cache files
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Encryption/Decryption cache files

 Post Reply Post Reply
Author
prempos View Drop Down
Newbie
Newbie


Joined: 09-Apr-2011
Posts: 5
Post Options Post Options   Quote prempos Quote  Post ReplyReply Direct Link To This Post Topic: Encryption/Decryption cache files
    Posted: 18-Aug-2011 at 2:19pm
Thanks for the insight, we compiled using the modification suggested and all is well.

thanks again.

Pierre & Kevin
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2011 at 4:05pm
Instead of using the CryptoFns.SimpleDESDecrypt and other logic from that learning unit, I would recommend using chained streams.  You can find an example (for DevForce 2010 but still applicable to Classic) here - http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-save-restore-chained-streams
 
The SimpleDESDecrypt method is working on the entire encrypted string at one time and not in chunks, and it also allocates a MemoryStream without providing an initial capacity, which might be causing the problem.  I don't want to post the source code here, but I can provide the code for the SimpleDESEncrypt and SimpleDESDecrypt functions if you want to try tweaking them to see if the problem goes away.  PM or email me if interested.
 
Regarding saving and restoring smaller EntitySets, we don't have any samples of this I'm afraid.  The Developer's Guide has a general discussion on multiple EntitySets in the "Disconnected" chapter.  The PM.SaveEntitySet method has several overloads which allow you to pass only the entities of interest.  So for example, you could use PM.GetEntities to retrieve Customers, and then pass that EntityList or array into the SaveEntitySet method.
Back to Top
kjohnson View Drop Down
Newbie
Newbie


Joined: 19-Nov-2008
Posts: 19
Post Options Post Options   Quote kjohnson Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2011 at 2:12pm
I'm also working on the program experiencing the System.OutOfMemoryException error and wanted to add in a few things.

We are using sample code from the Security Encrypting a Local Cache File learning unit. The main modification we made to the code is to help in catching errors. And as was mentioned previously we are receiving this error when we attempt to decrypt the EntitySet before restoring it.

Saving and restoring smaller EntitySets would be helpful in correcting this problem, but I didn't see anything in the learning units regarding this. Are there any resources or samples that would show how to cache only objects of EntityType Customer to a local cache file?
Back to Top
prempos View Drop Down
Newbie
Newbie


Joined: 09-Apr-2011
Posts: 5
Post Options Post Options   Quote prempos Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2011 at 1:50pm
Thanks for the Head up...

The error occurs only when trying to decrypt, no errors with envryption.

Thank you for the suggestions, I appreciate that.

Also, we are using  the IdeaBlade.Util.CryptoFns.SimpleDESEncrypt() method

Pierre
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 17-Aug-2011 at 12:48pm
Afraid we can't help with the differences between WEPOS and Windows 7 (a WEPOS forum might be able to help with why 2G of memory could be sufficient in standard Windows but not WEPOS), but we can help troubleshoot the general out-of-memory problem.
You didn't say how you're doing encryption/decryption.  Are you using sample code from one of the learning units or your own?
 
Is the error specifically occuring during decryption or somewhere within the PM.RestoreEntitySet or EntitySet.Load logic?  The load/restore logic uses a BinaryFormatter to deserialize the provided stream, and doesn't have any knobs to control its behavior. 
 
A few things to look at would be -
  • An out-of-memory problem during serialization or deserialization is usually due to problems with the allocation of progressively larger buffers. You can sometimes fix this by setting the capacity on a *Stream or StringBuilder in its constructor to the size needed.  
  • Try calling GC.Collect before doing the restore.
  • Think about saving and restoring smaller EntitySets.  Instead of caching all entities within a PM into a single file, maybe create smaller cache files by functionality or feature.
  • Try using the EntityDataSetSurrogate directly.  This is the what is actually used under the hood.  If you serialize/deserialize it directly you'll have more control over this logic. 
 
Back to Top
prempos View Drop Down
Newbie
Newbie


Joined: 09-Apr-2011
Posts: 5
Post Options Post Options   Quote prempos Quote  Post ReplyReply Direct Link To This Post Posted: 16-Aug-2011 at 6:55pm
Hello,

We are getting an "Exception of type" System.OutOfMemoryException" was thrown

when reading cache file, and decrypting cache file in the debug log file. The computer is a wepos2010 (windows embeded pos) with 2 GB memory. WEPOS is the scaled down OS from windows XP Microsoft

Any thoughts.

This same build seems to work fine on windows7 systems with 2 GB memory.

Thanks.
Pierre
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down