web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Using Web Api with dynamics 365 Online

(0) ShareShare
ReportReport
Posted on by

I am using the Web API in the plugins on CRM Online 2016.

I know that when registering the plugin assembly on server, it's a bad practice to merge the CRM assemblies provided by microsoft.

However, not including 'Microsoft.IdentityModel.Clients.ActiveDirectory' in assembly gave me this error :

Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.1.741, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.


So, i included this in the assembly and the assembly got registered on CRM online.

 But during runtime, i got this error :

An exception occurred during the initialization of the Plug-in Profiler.
Unhandled Exception: System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

It looks this has something to do with the sandbox mode restrictions.

Any pointers on how to fix it?

*This post is locked for comments

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Easy answer - don't use WebApi from plugins. Why do you need it? You still can use IOrganizationService retrieved from plugin context.

  • Community Member Profile Picture
    on at

    Web API is based on open data protocol based on REST, easy to use using http methods and supports oauth and Microsoft suggests to use web API over SOAP organization end point and will soon deprecate it.. There are many reasons.

    I would like to use Web API and I am sure it can be used from plugins or any server or client side code.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Ok. Good luck solving issues with auth, assemblies and sandboxing. Just take a look on following - msdn.microsoft.com/.../mt608128.aspx especially:

    If you’re a .NET developer with no requirements to support other platforms, you don’t have to move to the Web API right away.

  • Community Member Profile Picture
    on at

    MS has clearly documented "At this time you can’t easily use the Web API for code that runs on the server, such as in plug-ins or workflow assemblies." I lost it between all the buzz going around new Web API :)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans