Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi i have A WPF Application That use .Net Frameword 4 And Build in Any CPU Mode.
i have A Window To Backup And Restore Software Database by Bellow Code:

C#
private void GetBackup(object sender, RoutedEventArgs e)
{
    System.Windows.Forms.SaveFileDialog SF = new System.Windows.Forms.SaveFileDialog();
    SF.Title = "Save Backup File";
    SF.Filter = "Standard Zip File (*.Zip) |*.zip";
    if (SF.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        DBConnection.GetBackup(SF.FileName);
        MessageBox.Show("Backup Complete.", "Backup Manager", MessageBoxButton.OK, MessageBoxImage.Information);
    }
}

private void RestorBackup(object sender, RoutedEventArgs e)
{
    System.Windows.Forms.OpenFileDialog RF = new System.Windows.Forms.OpenFileDialog();
    RF.Title = "Restor Backup File";
    RF.Filter = "Standard Zip File (*.Zip) |*.zip";
    if (RF.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        DBConnection.RetBackup(RF.FileName);
        MessageBox.Show("Restor Complete.", "Backup Manager", MessageBoxButton.OK, MessageBoxImage.Information);
    }
}


Now I Get FetalExecutionEngineError When Call RF/SF.ShowDialog() Line.
What is Problem?

Note: i Use Access 2010 DataBase (Microsoft.ACE.OLEDB.12.0).

Help Me Please!
Posted
Comments
Sergey Alexandrovich Kryukov 15-Oct-12 13:35pm    
Ever heard of Copy/Paste?! :-)
--SA
MEkramy 15-Oct-12 13:39pm    
What you're Mean? :-|
My Question is not Clear?
Just Help me :)
Thanks!
Sergey Alexandrovich Kryukov 15-Oct-12 14:09pm    
If you used Copy/Paste, you would not spell something which does not exist: "FetalExecutionEngineError". Nobody can help you if you are not bothering enough about helping yourself.
--SA
MEkramy 15-Oct-12 14:34pm    
Ok, i'm sorry, i Can't Speek english Well, So maybe my question is not clear!
Anyway Thanks.
Sergey Alexandrovich Kryukov 15-Oct-12 14:49pm    
It's OK, not a big deal, especially if you do yourself a favor and use a spell checker. I'm mostly using the one which comes with the Web browser; as my English is far from perfect, it helps me a lot. And it will really help you to get better answers.
--SA

You're using a Windows.Forms control in a WPF app. The two technologies are not compatbile with each other and won't work unless you take precautions to host the controls properly.

See this stuff[^].
 
Share this answer
 
Comments
MEkramy 15-Oct-12 14:07pm    
Thanks Dave.
But Its Not Correct. its work in new WPF Application But in this app not.
just Test it;
1. Add System.windows.Froms To Your Refrences
2. System.Windows.Forms.OpenFileDialog OF=new System.Windows.Forms.OpenFileDialog();
OF.ShowDialog();

:)
MEkramy 15-Oct-12 14:43pm    
i Get This Message:

FatalExecutionEngineError was detected
Message: The runtime has encountered a fatal error. The address of the error was at 0xe8bfc200, on thread 0x247c. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Sergey Alexandrovich Kryukov 15-Oct-12 14:56pm    
You are write, but dialogs are somewhat different; in certain cases, the Forms dialogs can work with WPF -- I tried a while ago. I advised OP what is recommended to use instead, please see my answer.
--SA
Richard MacCutchan 15-Oct-12 15:01pm    
@Dave: I just tested this in a simple WPF app and it worked with no problem. I suspect there is something more going on that the OP has not told us.
Richard MacCutchan 15-Oct-12 15:06pm    
Scrub that, I just found MSDN notes on how to do it.
Even though the dialogs you've uses might work under WPF in certain cases, this is not what you should use.

For a message box, you need to use System.Windows.MessageBox:
http://msdn.microsoft.com/en-us/library/system.windows.messagebox.aspx[^].

For common dialogs like file open, Microsoft recommends to use Microsoft.Win32 dialogs.

For overview, please see:
http://msdn.microsoft.com/en-us/library/aa969773.aspx[^].

—SA
 
Share this answer
 
Comments
MEkramy 15-Oct-12 15:09pm    
Thanks, i Use it before, but i give same error.
Sergey Alexandrovich Kryukov 15-Oct-12 15:22pm    
I'm not sure. At least, revert back to right use, re-test it. It there is a problem, debug it thoroughly, change your question with new/old code, use "Improve question" above.
One step at a time.
--SA
Oh my godness ..I just enter to see what in the name of the Lord was "FetalExecution"...now I know...it's related to the System.Abortion class...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900