Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

Posted on by 156

Background info:

ADX Portal Version: 7.0.0022

CRM 2016 On-Premise.

ADX Portal site is running on IIS server.

We have converted to using Early Bound per the instructions that ADX provided in a webinar:

http://community.adxstudio.com/events/upgrading-to-adxstudio-portals-v7

---------------------------------------------------------------------------------------------------------

Issue:

Today I am getting an Invalid Cast Exception.

Server Error in '/' Application.


Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

[InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.]

As anyone experienced this with early bound in version 7 portals?

*This post is locked for comments

  • Verified answer
    jestuder Profile Picture
    jestuder 156 on at
    RE: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.
            /// <summary>
            /// The current adx_website <see cref="Entity"/>.
            /// </summary>
            //public Adx_website Website
            //{
            //    get { return (Adx_website)Portal.Website; }
            //}
    
            public Entity Website
            {
                get { return Portal.Website; }
            }

    Above is the code we changed. We basically changed Adx_website to entity and changed the return.
  • Brian_Illand Profile Picture
    Brian_Illand on at
    RE: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

    Did you ever get this sorted jstuder  - I am getting the exact same issue in PortalPage.cs in ADX V7.

  • jestuder Profile Picture
    jestuder 156 on at
    RE: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

    Can anyone point me in the right direction of how to fix this?  I understand the enable proxy types.  I just don't know where to put that.

  • jestuder Profile Picture
    jestuder 156 on at
    RE: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

    Thats what I have read that I need to do.  The problem is this is my first go with ADX Studio and I can't figure out where to put the code snippet as it doesn't appear that the Organization Service Proxy is used in ADX code.

  • Suggested answer
    Marius Agur Pedersen Profile Picture
    Marius Agur Pedersen 1,771 on at
    RE: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Xrm.Adx_website'.

    Have you remembered to enable proxy types for your assembly?

    On your organization service proxy, run the following:

    serviceProxy.EnableProxyTypes()

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans