This is a migrated thread and some comments may be shown as answers.

Unable to cast object of type 'Telerik.Web.UI.PostedFile' to type 'Telerik.Web.UI.UploadedFile'.

3 Answers 116 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
vishesh kumar
Top achievements
Rank 1
vishesh kumar asked on 27 Jan 2010, 08:21 AM
Hi,

I am creating a project (business objects ) with a reference to the .20 assembly. When i try to iterate over the files in the radupload.uploaded files collection, I get this exception

Unable to cast object of type 'Telerik.Web.UI.PostedFile' to type 'Telerik.Web.UI.UploadedFile'.

I am not able to fix it.

Then i tried addding the reference to the .35 assembly of Telerik.web.ui and then i got a compile time error stating

Error 271 Assembly "XXX" uses 'Telerik.Web.UI, Version=2009.2.826.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' which has a higher version than referenced assembly 'Telerik.Web.UI, Version=2009.2.826.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4'

What should i do?
Help!!

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 27 Jan 2010, 12:50 PM
Hi vishesh kumar,

Can you please paste here the code that you use to iterate over the uploaded files?

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
vishesh kumar
Top achievements
Rank 1
answered on 27 Jan 2010, 12:58 PM
public bool ValidateFile()
        {
            bool isFileValidated = false;
            
            foreach (UploadedFile file in this.files)
            {
                if (true == this.extensions.Contains(file.GetExtension()) &&
                    true == this.mimeTypes.Contains(file.ContentType) &&
                file.ContentLength <  this.contentLength*1000000)
                {
                    isFileValidated = true;
                }
                else
                {
                    isFileValidated = false;
                    break;
                }
            }
            return isFileValidated;
        }
Here this.files is the uploadedfilecollection
0
Genady Sergeev
Telerik team
answered on 29 Jan 2010, 04:41 PM
Hello vishesh kumar,

This code should not throw any errors since the UploadedFilesCollection returns UploadedFile. I tried to reproduce the problem on my side, however no avail, I managed to successfully iterate over the uploaded files collection. Can you give us more details regarding your scenario? Are you sure that this.files returns UploadedFilesCollection? How do you populate that collection?

Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Upload (Obsolete)
Asked by
vishesh kumar
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
vishesh kumar
Top achievements
Rank 1
Share this question
or