سؤال

Currently on my website i am trying to get it so that a user can upload an image from their local images. I have followed a tutorial, but when i debug it and try to open up my images folder i get this error message:

"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."

Please can someone help me here, i have read a few posts; but seen as this is my first time doing this; i dont really understand them.

Thanks for any response!

هل كانت مفيدة؟

المحلول

You are trying to use Windows Forms functionality in a ASP.NET Web Page. Line 140:

FileDialog fldlg = new OpenFileDialog();

Windows Forms is desktop technology. You can't mix that with a ASP.NET web app. You can use the FileUploadControl to enable file uploads in your web application:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top