Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试通过访问 passwordBox 值时
string str= passwordBox1.Password
在一个函数中,我得到以下异常:
无效的跨线程访问。
故障排除提示:如果您尝试访问文件,请确保它不是只读的。
您可能正在尝试从非 UI 线程访问 Control。 尝试将该代码包装在Deployment.Current.Dispatcher.BeginInvoke()函数中,如下所示:
Deployment.Current.Dispatcher.BeginInvoke()
Deployment.Current.Dispatcher.BeginInvoke(() => { string str= passwordBox1.Password ... });