Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:00:55+00:00 2026-05-25T00:00:55+00:00

I have the classes: [DataContract] public class MediaItem : Video { //used to protect

  • 0

I have the classes:

    [DataContract]
    public class MediaItem : Video
    {
        //used to protect calling api from the incorrectly named video
    }

    [DataContract]
    public class SecureMediaItem : MediaItem
    {
        [DataMember]
        public PlayerEmbedToken Token;
    }

Then I have the following code:

List<MediaItem> dummyItems = new List<MediaItem>();

 //cast the media item into a secure media item
SecureMediaItem retItem = (SecureMediaItem)dummyItems[mediaId];

//TODO: put in the Admin ID
retItem.Token.UserId = 1;
retItem.Token.IpAddress = VLSCore2.VlsSecurity.ParseIpFromString(ipAddress);
retItem.Token.UniquePlayerRef = Guid.NewGuid().ToString();


return retItem;

However Im getting an error:

Unable to cast object of type
‘VLSCore2.Entities.Security.Api.MediaItem’ to type
‘VLSCore2.Entities.Security.Api.SecureMediaItem’.

This is just simply a widending cast is it not? Something stopping it like the DataContract attribute?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:00:55+00:00Added an answer on May 25, 2026 at 12:00 am

    No. It’s the opposite of a widening cast. SecureMediaItem is more specific than MediaItem. You could cast a SecureMediaItem to a MediaItem, because a SecureMediaItem is a MediaItem. The other way around isn’t working, because a MediaItem isn’t necessarily a SecureMediaItem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these classes: [DataContract] public class ErrorBase {} [DataContract] public class FileMissingError: ErrorBase
I have de folowing classes : [DataContract] public class MyProject { [DataMember(Name = Branches)]
I have the following classes: [DataContract] [KnownType(typeof(SpecifiedItemCollection))] public class ItemCollection<T> : IEnumerable where T
I have two classes as below: [DataContract] public class Address { [DataMember] public string
I have classes structured like this: Public MustInherit Class A ' several properties End
If I have classes of Type A and B: public class A { public
How do I define DataContract for abstract classes in WCF? I have a class
I have created many class as my data class i.e: [DataContract] public class pCity
I have an abstract class called 'Template' defined as: [DataContract] public abstract class Template
I have classes that are named exactly the same across different plug-ins that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.