|
Advertisement? Its open source
|
|
|
|
|
These forums are for asking questions not for product endorsements. Since it's open source why not write an article about your efforts and share it here.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
I'm using BinaryFormatter to serialize/deserialize some of my custom classes. On my development PC, everything is working fine but this morning, I installed the app on another PC and tried to load (deserialize) one the files. The object is deserialized with no errors but the string field: "ContactName" is null!
Keep in mind that my development PC loads the file perfectly and I manually copied the same .exe and all Dlls from the dev PC to the other PC.
Here's the code sample:
//
//Deserialization...
//
BinaryFormatter bf = new BinaryFormatter();
using (FileStream fs = File.Open(filePath, FileMode.Open))
{ _SelectedTemplate = (LabelTemplate)bf.Deserialize(fs); }
I'm I going crazy or do I send a nasty comment to Microsoft?
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Richard Blythe wrote: Keep in mind that my development PC loads the file perfectly and I manually copied the same .exe and all Dlls from the dev PC to the other PC.
And what about the data file, is that the same on both PC?
Keep in mind thousands of developer (including me!) used serialization without a hitch for a long while!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
You're not going crazy; .NET serialization is full of bugs. Things don't work as advertised, and you have to come up with time-consuming workarounds.
This is an example of what I call a "black-box failure", when a component you depend on, that you don't have the source code for malfunctions. It can be devastating, since you can't fix it.
The standard approach to a black-box failure is to try to find a different way of doing the same thing. Another tactic is to upgrade to a later version of .NET, where the bug may have been fixed.
|
|
|
|
|
Hello everyone,
I have a managed C# app that I have inherited and I have another GUI application that is written using Qt and OpenGL. What I would like to do is create an instance of my unmanaged GUI window from the managed app and have the managed app ...well...manage it. So, somehow to integrate this window into the GUI of the managed app.
Also, how can one pass data between the host managed app and the unmanaged app window? Is there any painless to do this?
Cheers,
Keith
|
|
|
|
|
|
When I have more than one video playing at same time they start flickering - on my desktop this behavior doesn't happen but only in my notebook, but I suppose this problem could also happen for other people's computer so I want to fix it. Do you know how can I do that?
Here is the code:
public partial class Form1 : Form
{
Panel panel;
Panel panel2;
Video video;
Video video2;
public Form1()
{
InitializeComponent();
panel = new Panel();
Controls.Add(panel);
video = new Video("VIDEO1.MPG");
video.Owner = panel;
video.Play();
panel.Size = new Size(128, 128);
panel2 = new Panel();
Controls.Add(panel2);
video2 = new Video("VIDEO2.MPG");
video2.Owner = panel2;
video2.Play();
panel2.Size = new Size(128, 128);
panel2.Location = new Point(panel.Location.X + panel.Width, panel.Location.Y);
}
}
Just to remember that if just one video and panel is used, the video is played normally, smoothly, the problem happens when the second video is also added with its respective panel.
Thanks in advance,
modified on Thursday, April 22, 2010 12:21 PM
|
|
|
|
|
I am trying to pop up a modeless dialog box using .Show()
It does pop up the dialog, but it freezes and the components never load.
I can open the same dialog with .ShowDialog() and it loads properly.
But that doesn't accomplish what I am looking for in the dialog because i need it to be modeless.
So, is there something that I am missing to make show work correctly?
It is a pretty simple out of the box dialog that I am testing with, just from VS2008 designer with one button on it.
|
|
|
|
|
so it seems something goes wrong in the Form's Load event handler.
|
|
|
|
|
I don't have anything in any of the handlers. It has pretty much nothing in it. I put one button on it that doesn't do anything. (I was just testing).
The only code in it is the
public ChatMessageForm()<br />
{<br />
InitializeComponent();<br />
}<br />
|
|
|
|
|
In this case, source code is the only thing that will help us solve your problem. This includes the code surrounding your chatMessageForm.Show() method.
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Well the code looks a bit like this.....
public partial class ChatMessageForm : Form<br />
{<br />
public ChatMessageForm()<br />
{<br />
InitializeComponent();<br />
}<br />
}
private void ProcessChatMessageEvent()<br />
{<br />
ChatMessageForm c = new ChatMessageForm();<br />
c.Show();<br />
<br />
}<br />
ProcessChatMessageEvent is called by.....
public void OnEvent(Object sender, EventPublisher.EventPublisherEventArgs eventArgs)<br />
{<br />
EventID nReceivedEvent = (EventID)eventArgs.iEventID;<br />
switch (nReceivedEvent)<br />
{<br />
case EventID.eChatMessageEvent:<br />
ProcessChatMessageEvent();<br />
break;<br />
}<br />
}
I checked and it works properly outside of the switch which kinda amazes me.
(The OnEvent is a Cisco event handler)
|
|
|
|
|
aei_totten wrote: works properly outside of the switch
Hmm, so your saying that the following code would work:
public void OnEvent(Object sender, EventPublisher.EventPublisherEventArgs eventArgs)
{
ProcessChatMessageEvent();
}
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Richard Blythe wrote: Hmm, so your saying that the following code would work:
yes
|
|
|
|
|
well crud. I can't even reproduce that today
|
|
|
|
|
The difference between Show and ShowDialog is that the first method displays the form and continues with the next line of code, while the second method pauses execution of the code until after the form has been closed. Observe:
MyForm F = new MyForm();
F.ShowDialog();
System.Diagnostics.Debug.WriteLine("Output");
In this case, the string Output will not be written to the Immediate window until the pop-up form is closed. If you replace F.ShowDialog() with F.Show() , Output will probably be written before the form finishes rendering.
I suspect that your calling code needs to wait until the dialog has been handled, which is why ShowDialog works and Show does not. This can be a real pain if you are writing a MDI application, as child windows cannot be invoked with ShowDialog .
Added: After looking at the code you posted above, I can see the problem. After calling Show() , the method ends. The variable referencing your form goes out of scope and gets recycled: your form is not getting a chance to render before it gets disposed. If it absolutely has to be modeless, you will need to move the scope of your form's variable out.
|
|
|
|
|
Gregory.Gadow wrote: Added: After looking at the code you posted above, I can see the problem. After calling Show(), the method ends. The variable referencing your form goes out of scope and gets recycled: your form is not getting a chance to render before it gets disposed. If it absolutely has to be modeless, you will need to move the scope of your form's variable out.
Now, that makes sense.
However, in the real application, I have more demands of that form (I just wanted to get a simple one working first because I was running into this issue and couldn't pin point it).
Here's some code....
private Dictionary<string, ChatMessageForm> chatMessages = new Dictionary<string, ChatMessageForm>();<br />
...<br />
string message, sender; <br />
message = "blah";<br />
sender = "me";<br />
if (!chatMessages.ContainsKey(sender))<br />
{<br />
chatMessages.Add(sender, new ChatMessageForm(sender));<br />
}<br />
chatMessages[sender].ShowDialog();}
The Dictionary is declared outside of the process in the scope of the main form. However, i do think the issue is related. This is my first time using Dictionary so maybe I am missing something there...
|
|
|
|
|
Found out something else.
Even without the Dictionary, just moving the declaration of the Form out into the scope of the main form was not enough to fix the problem
|
|
|
|
|
Based on your last post, it seems that you need to look into the Cisco event behavior. For example, a standard windows event will not give you this behavior. Try trapping an event from your main form like this:
public frmMain()
{
InitializeComponent();
frmMain.Click += new EventHandler(frmMain_Click);
}
ChatForm frmChat;
void frmMain_Click(object sender, EventArgs e)
{
if (frmChat == null)
{
frmChat = new ChatForm();
frmChat.Show();
}
frmChat.BringToFront();
}
If this works without a hitch (which it should), then you should contact Cisco and report a bug!
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
Thanks for the relpy. It does work fine from a button event or other main form generated event.
However, I created a System.Timers.Timer and called the method from it's elapsed event handler and that created the same freeze as seen from the Cisco event handler.
|
|
|
|
|
Okay, maybe it's a thread issue. Most of my apps doesn't required thread sensitive code. Try using thread context code like this:
...
{
InvokeMethod();
}
private delegate void EmptyHandler();
private void InvokeMethod()
{
if (this.InvokeRequired)
this.Invoke(new EmptyHandler(InvokeMethod), null);
else
{
ChatForm frmChat = new ChatForm();
frmChat.Show();
}
}
This create the new chat for on the same thread as the main form.
Maybe a long shot, but it may be what your looking for...
Cheers,
Richard
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|
|
That did it.
I had tried previously checking if the dialog needed invoke but i didn't check this.invokerequired
Thanks so much!
|
|
|
|
|
Great! I was a pro and didn't even know it.
Maybe you'll have the answer for me when I need it.
If my answer has helped you, one of my articles may also be a help. Also remember that your best friend's name is google.
|
|
|
|