문제

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