Im having a similar problem. I was able to reproduce it. I create new windows form, add a new data source (an access data base file, with only one table). Then drag the table to the form. Then add a new button and the following code.
private void Test()
{
this.table1TableAdapter.GetData();
}
private void SaveDialogTest()
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Text File|*.txt";
saveFileDialog1.InitialDirectory = Application.StartupPath;
saveFileDialog1.Title = "test";
saveFileDialog1.ShowDialog();:mad:
if (saveFileDialog1.FileName != "")
{ }
}
private void button1_Click(object sender, EventArgs e)
{
Test();
SaveDialogTest();
}
The table adapter is created by the designer:
private void Form1_Load(object sender, EventArgs e)
{
this.table1TableAdapter.Fill(this.testDataSet.Table1);
}
When I run the form and click on the button I get an
AccessViolationException
, when calling
saveFileDialog1.ShowDialog()
.
If i move the "
Test()
" method inside the "
Form1_Load
" method everything works fine.
Also if I run the dialog first, before calling GetData() everything works fine afterwards. Like this.
SaveDialogTest();
Test();
SaveDialogTest();
This will call the second
SaveDialogTest()
without exception.
Also if I compile it and run it in and XP pc everything works fine.
Data Source: Microsoft Access Database File (OLE DB)
Im using Visual Studio 2008 SP1. Windows 7