Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Memory mismatch with Microsoft.DocAsCode.Plugin #8247

Closed
RobJessop opened this issue Nov 17, 2022 · 5 comments
Closed

System.Memory mismatch with Microsoft.DocAsCode.Plugin #8247

RobJessop opened this issue Nov 17, 2022 · 5 comments
Labels
dotnet Generate .NET API reference docs extensibility Extend the platform to support new languages, new outputs and custom behaviors

Comments

@RobJessop
Copy link
Contributor

Operating System: Windows

DocFX Version Used: 2.59.4

Template used: custom template + custom plugin

Steps to Reproduce:

  1. Create a plugin with Microsoft.DocAsCode.Plugin 2.59.4 nuget package
  2. Use it in a project with C# API

Expected Behavior:
Plugin is loaded and executed

Actual Behavior:
An exception is raised about an unexpected System.Memory.dll version e.g.:

[22-11-17 12:03:17.070]Error:System.IO.FileLoadException: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
   at System.Reflection.RuntimeMethodInfo.GetParameters()
   at Newtonsoft.Json.Serialization.DefaultContractResolver.GetCallbackMethodsForType(Type type, List`1& onSerializing, List`1& onSerialized, List`1& onDeserializing, List`1& onDeserialized, List`1& onError)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveCallbackMethods(JsonContract contract, Type t)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateArrayContract(Type objectType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, JsonSerializerSettings settings)
   at Microsoft.DocAsCode.Build.Engine.Incrementals.IncrementalBuildContext.ComputeConfigHash(DocumentBuildParameters parameter, String markdownServiceContextHash) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\Incrementals\IncrementalBuildContext.cs:line 609
   at Microsoft.DocAsCode.Build.Engine.Incrementals.IncrementalBuildContext.Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, String intermediateFolder, String markdownServiceContextHash) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\Incrementals\IncrementalBuildContext.cs:line 86
   at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.Prepare(DocumentBuildParameters parameters, DocumentBuildContext context, TemplateProcessor templateProcessor, String markdownServiceContextHash, IHostServiceCreator& hostServiceCreator, PhaseProcessor& phaseProcessor) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\SingleDocumentBuilder.cs:line 244
   at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.BuildCore(DocumentBuildParameters parameters) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\SingleDocumentBuilder.cs:line 105
   at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.Build(DocumentBuildParameters parameters) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\SingleDocumentBuilder.cs:line 75
   at Microsoft.DocAsCode.Build.Engine.DocumentBuilder.BuildCore(DocumentBuildParameters parameter, IMarkdownServiceProvider markdownServiceProvider, BuildInfo currentBuildInfo, BuildInfo lastBuildInfo) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\DocumentBuilder.cs:line 363
   at Microsoft.DocAsCode.Build.Engine.DocumentBuilder.Build(IList`1 parameters, String outputDirectory) in C:\Users\RobertJessop\Work\docfx\src\Microsoft.DocAsCode.Build.Engine\DocumentBuilder.cs:line 309
   at Microsoft.DocAsCode.SubCommands.DocumentBuilderWrapper.BuildDocument(BuildJsonConfig config, TemplateManager templateManager, String baseDirectory, String outputDirectory, String pluginDirectory, String templateDirectory) in C:\Users\RobertJessop\Work\docfx\src\docfx\SubCommands\DocumentBuilderWrapper.cs:line 148
   at Microsoft.DocAsCode.SubCommands.DocumentBuilderWrapper.BuildDocument() in C:\Users\RobertJessop\Work\docfx\src\docfx\SubCommands\DocumentBuilderWrapper.cs:line 84
=== Pre-bind state information ===
LOG: DisplayName = System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Users/RobertJessop/Work/docfx/src/docfx/bin/Debug/net472/
LOG: Initial PrivatePath = C:\Users\RobertJessop\Work\docfx\src\docfx\bin\Debug\net472\;C:\Users\RobertJessop\Work\docfx\src\docfx\bin\Debug\net472\plugins_dvkvvyml.i13\plugins
Calling assembly : System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Users/RobertJessop/Work/docfx/src/docfx/bin/Debug/net472/System.Memory.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Reverting this change alleviates this particular problem but would obviously reintroduce the problem it solved: #8135

Alternatives I tried that didn't seem to work:

  • Manually adding a reference to System.Memory 4.5.5 to my plugin project (4.5.4 still seemed to be expected in the DocFX build)
@jo3w4rd
Copy link
Contributor

jo3w4rd commented Nov 17, 2022

I deleted System.Memory.dll from the DocFX install. That was the only thing that worked for me.

@RobJessop
Copy link
Contributor Author

I expect it would then fall through to checking the temporary plugins_<blah> path (the second part of the PrivatePath in the log) which does have the expected version. I'm not confident that there won't be side effects of removing that DLL though.

@nprorekhin
Copy link

Hi, I confirm this behavior with the memberpage 2.59.4 plugin.
It looks like the memberpage plugin uses System.Memory, Version=4.0.1.1 while DocFX uses System.Memory, Version=4.0.1.2
If you delete System.Memory.dll from the DocFX, the memberpage plugin loads the required DLL from it's own folder and it works. However docfx pdf command stops working , since it doesn't use the memberpage plugin and fails to find the deleted System.Memory.dll

@zp-zpanda
Copy link
Contributor

Me too. 2.59.3 works fine.

@yufeih yufeih added dotnet Generate .NET API reference docs extensibility Extend the platform to support new languages, new outputs and custom behaviors labels Dec 15, 2022
@yufeih
Copy link
Contributor

yufeih commented Jan 30, 2023

This is resolved in the latest version with a new library based plugin model, see this sample on using the member page plugin with the new approach.

@yufeih yufeih closed this as completed Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Generate .NET API reference docs extensibility Extend the platform to support new languages, new outputs and custom behaviors
Projects
None yet
Development

No branches or pull requests

5 participants