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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

MethodAccessException: Attempt by method X to access method Y failed in Dynamics 365 Plugin On Prem

(0) ShareShare
ReportReport
Posted on by 80

I'm getting the error below when trying to move a plugin from version .NET version 4.5.2 to 4.6.2 in Dynamics 365 v9.1

 System.AggregateException: One or more errors occurred. ---> System.MethodAccessException: Attempt by method 'System.Net.Http.WinHttpResponseParser.GetReasonPhrase(System.Net.HttpStatusCode, Char[], Int32)' to access method 'System.Net.HttpStatusDescription.Get(System.Net.HttpStatusCode)' failed.
   at System.Net.Http.WinHttpResponseParser.GetReasonPhrase(HttpStatusCode statusCode, Char[] buffer, Int32 bufferLength)
   at System.Net.Http.WinHttpResponseParser.CreateResponseMessage(WinHttpRequestState state, Boolean doManualDecompressionCheck)
   at System.Net.Http.WinHttpHandler.<StartRequest>d__103.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)

I can deploy the plugin and it works fine. I'm getting the error above when the plugin attempts to make a web service call to an external API we call from the plugin

The plugin is NOT in sandbox mode and it's registered in the database 

pastedimage1648793778063v2.png

I opened the plugin assembly with JustDecompile and tracked down the issue to loading a method in System.dll, it looks like it's trying to load it from the GAC and fails.

pastedimage1648793778064v3.png

Anyone had the same issue? This same plugin works in .NET 4.5.2 but fails in 4.6.2

I have the same question (0)
  • Suggested answer
    juancho Profile Picture
    80 on at

    We managed to find a solution for this, the problem was ILMerge was including all System.*.dll, reading in this stackoverflow answer https://stackoverflow.com/a/67334636/2059998

    You might want to avoid merging anything that's part of the .NET Framework (which I assume that libraries like System.Memory and System.Threading.Tasks are).

    So adding the line <Files Remove="$(TargetDir)System*.dll" /> for ILMerge in the .NET project file fixed the issue, this makes sure the files are not included when running ILMerge

    <Target Name="ILMerge" AfterTargets="Build">
    <ItemGroup>
        <Files Include="$(TargetDir)*.dll" />
        <Files Remove="$(TargetDir)$(AssemblyName).dll" /> 
        <Files Remove="$(TargetDir)AntiXSSLibrary.dll" />
        <Files Remove="$(TargetDir)Microsoft*.dll" />
        <Files Remove="$(TargetDir)System*.dll" />
    </ItemGroup>

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 62 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans