|
no no no thanks... I HAVE IT!
/\ |_ E X E GG
|
|
|
|
|
Hello, I have a slight problem. I have an application written in Java, but i'm rewriting it to C# currently. Now i've run into some problems since some parts of the save procedure used java serialization (of a hashtable).
Of course I need to be able to still read files made with the java version, but how can this be done? basically I would need to decode the serialized java object. Is there any documentation to be found on this subject?
does anyone have an idea?
|
|
|
|
|
misterbear wrote:
does anyone have an idea?
Yap: check on Sun's site if there is any doc on how the standard hashtables are serialized!
Once you know that,
open the files, and read them into a C# Hashtable as needed.
HTH,
F.O.R.
|
|
|
|
|
Keep in mind that the objects in the hashtable were also serialized. For the most part, if you were to use simply objects in a Java hashtable and save that to a file (I'm thinking just a simple test class with String members), you could also reverse engineer it. That wouldn't be so hard using your favorite hex editor. Depending on the complexity of the objects within it, though, that's another story.
If nothing else and worse comes to worse, you could always use the JNI concepts I cover in my article, Embedding .NET Controls in Java. The content of the article doesn't apply so much as the concept does - using JNI to bridge the gab between .NET and Java. A JNI Win32 DLL (not a managed assembly - Java won't know how to load it) to use Java calls to deserialize a hashtable and pass the members to .NET, or could even use late binding and the unmanaged CLR methods to get your .NET assembly to serialize the hashtable. Basically, this idea would be a one-time conversion utility (I recommend not overriding the old file though, or you should at least back it up).
Obviously, deserializing the hashtable would be preferred (and most likely not hard to do), but the latter idea could be handy in a worse-case scenario.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks for the help. fortunately my hashtable is expected to contain strings only and i've found out they have a very simple serialization scheme so I'm starting to get the hang of it now.. But there are still a couple of "mystic" bytes in there =)
|
|
|
|
|
here's the code...
private void menuItem2_Click(object sender, System.EventArgs e)
{
StreamWriter fout;
if(this.saveFileDialog1.ShowDialog()==DialogResult.OK)
{
fout= new StreamWriter (new FileStream(this.saveFileDialog1.FileName, FileMode.Create));
<code>fout.Write(this.listBoxLog.Items.ToString());</code> fout.Close();
}
}
Now the line in bold...
What would I put to make it write out the whole listBox...
Or would I have to put it in an array or something first...?
/\ |_ E X E GG
|
|
|
|
|
I think this works:
foreach(Object <code>o</code> in <code>this</code>.<code>listBoxLog</code>.<code>Items</code>)
fout.Write((<code>string</code>)<code>o</code>);
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Thank you again...
/\ |_ E X E GG
|
|
|
|
|
Are dynamic textboxes or labels possible? Like for example you want to get a list of names and you want to put it in labels but you wouldnt know how many names will be sent?
"To teach is to learn twice"
|
|
|
|
|
Dynamic controls are very easy to implement. For example:
Label lblName ;
foreach(string sName in arrName)
{
lblName = New Label();
lblName.Text = sName;
myForm.Controls.Add(lblName);
}
God, I pity me! - Phoncible P. Bone
If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you
|
|
|
|
|
Is it possible to make a program in C# that will serve as the exe file for autorun cds? if not, wat software do I use?
"To teach is to learn twice"
|
|
|
|
|
|
But wud the executable run even without the .net framework on the other pc? If not, what is the most commom dev tool used to make an autorun executable?
"To teach is to learn twice"
|
|
|
|
|
daljv wrote:
But wud the executable run even without the .net framework on the other pc? If not, what is the most commom dev tool used to make an autorun executable?
If you use any CLS-compliant language you'll need the .NET redistributable on the target machine. An alternative is to use something like Macromedia Director or Macromedia Flash (make a standalone exe). You could also use the now obsolete VB6 (and hope that they have the VB runtime DLLs)
The safest approach would be to use HTML pages (you can then have gifs, jpgs, swf etc in sub directories)
Nish
Extending MFC Applications with the .NET Framework [NW] (My book with Tom)
Summer Love and Some more Cricket [NW] (My first novel)
Shog's review of SLASMC [NW]
Come with me if you want to live
|
|
|
|
|
but if html were to be used, wat wud i place in my autorun.inf?
|
|
|
|
|
|
Nishant S wrote:
You could also use the now obsolete VB6 (and hope that they have the VB runtime DLLs)
You'd be surprised if I tell you the number of projects done at present day using VB6.
- Kannan
|
|
|
|
|
|
But for windows client applications which needs to go into desktops of the masses, I guess people would still prefer using the RAD tools of the past.
I dont think its justified to download a 20mb runtime for a program that has a couple of dialogs. Probably thats one of the reasons we havent seen some cool products (something popular like winzip or a messenger).
- Kannan
|
|
|
|
|
Ok here is the scenario. I have an automated process manager that I am running, it is polling using the timer class every 10 minutes to see if something needs to be run.
If the window is FormWindowState.Normal the memory is between 11 - 21 meg which is fine, when I minimize the window it drops memory useage to around 600k, which is great.
However if I try to run GC after a poll and successful process run, the memory doesn't seem to get collected no matter what I try. I would expect memory to realease to at least 3 - 4 meg once the process is completed however when I call GC this doesnt happen, if I manually minimize the display the memory releases down to 600 - 800k. So I dont think I have references in place that should be there, its almost like GC doesnt fire until I minimize.
Any thoughts?
|
|
|
|
|
One other quick question is there an event that fires when FormWindowState property is changed? I cant find one in documentation but wanted to make sure I wasnt overlooking anything.
|
|
|
|
|
well you cant really force the GC to run your just asking it to.
implement the dispose method on those references and set them to null so you can force the release.
make sure no other object holds a reference to it or it will not release. Much like the old com refernece counter.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hello !
is there an efficient way to trim a byte[] to a new size?
i need this for a socket.receive:
byte[] data = new byte[1024]; //Input-Buffer
int recv = s.ReceiveFrom(data,ref sender);
i tried this:
byte[] trimmedData = new byte[recv];
for (int i = 0;i
|
|
|
|
|
The best way to do this is to use a vector<byte> and then you can just use resize().
[edit]
Whoops. Thought I was in the C++ forum. Sorry
[/edit]
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
I read the first line and thought," WHOA, we can do vectors in C# ??? ".
God, I pity me! - Phoncible P. Bone
If I end up Windows ME someone is going to be hurting. - One of the answers to a question for What OS are you
|
|
|
|