本文介绍了OpenFileDialog中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好会员,
我在使用OpenFileDialog时遇到异常,以下是代码
hello members,
i m getting an exception while working with OpenFileDialog,following is the code
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog f = new OpenFileDialog();
if(f.ShowDialog()==DialogResult.OK)
{
txtDoc.Text = f.FileName;
}
}
异常消息是:
必须先将当前线程设置为单线程单元(STA)模式,然后才能进行OLE调用.确保您的Main函数上已标记STAThreadAttribute.仅当将调试器附加到进程时,才会引发此异常.
请帮助我...为什么我要得到这个消息...我已经包含了所有必需的名称空间...
and the exception message is:
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
plz help me...why m i getting this msg...i have included all the necessary namespaces...
推荐答案
这篇关于OpenFileDialog中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!