Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Using Web Api with dynamics 365 Online

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Using Web Api with dynamics 365 Online

    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 :)

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Using Web Api with dynamics 365 Online

    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
    Community Member Microsoft Employee on at
    RE: Using Web Api with dynamics 365 Online

    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.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Using Web Api with dynamics 365 Online

    Hello,

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

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans