Closed niragvt closed 1 year ago
DocFX 2.58.9 ships with a System.Collections.Immutable.dll whose assembly name is "System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", and docfx.exe.config has an assembly binding redirection:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
However, plugins would use docfx.plugins.config (source) instead of docfx.exe.config. What plugins do you use?
I have this exact issue as well. Is there any known workaround? I tried locally going back a few versions, but met the same result.
This definitely has to do with the plugins used. If you are using the last modified processor, make sure to use the latest. Thats fixed my issues - https://github.com/Still34/DocFx.Plugin.LastModified/releases/tag/v1.2.5
Getting this as well on a fresh pc:
docfx metadata
just finedocfx build
Getting this same error as well.
How do I find the plugin?
I think I'm running into the same thing, although the error message is slightly different.
I have the memberpage plugin installed in Docs/plugins
, and the template section of my docfx.json
file (which is stored in Docs
) looks like this:
"template": [
"default",
"plugins/memberpage.2.59.4/content",
]
Running docfx metadata docfx.json
works completely fine, just like in @jemayn's case.
Running docfx build docfx.json
produces the following error:
[22-09-16 01:25:33.746]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 Microsoft.DocAsCode.Build.Engine.Incrementals.IncrementalBuildContext.ComputeConfigHash(DocumentBuildParameters parameter, String markdownServiceContextHash)
at Microsoft.DocAsCode.Build.Engine.Incrementals.IncrementalBuildContext.Create(DocumentBuildParameters parameters, BuildInfo cb, BuildInfo lb, String intermediateFolder, String markdownServiceContextHash)
at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.Prepare(DocumentBuildParameters parameters, DocumentBuildContext context, TemplateProcessor templateProcessor, String markdownServiceContextHash, IHostServiceCreator& hostServiceCreator, PhaseProcessor& phaseProcessor)
at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.BuildCore(DocumentBuildParameters parameters)
at Microsoft.DocAsCode.Build.Engine.SingleDocumentBuilder.Build(DocumentBuildParameters parameters)
at Microsoft.DocAsCode.Build.Engine.DocumentBuilder.BuildCore(DocumentBuildParameters parameter, IMarkdownServiceProvider markdownServiceProvider, BuildInfo currentBuildInfo, BuildInfo lastBuildInfo)
at Microsoft.DocAsCode.Build.Engine.DocumentBuilder.Build(IList`1 parameters, String outputDirectory)
at Microsoft.DocAsCode.SubCommands.DocumentBuilderWrapper.BuildDocument(BuildJsonConfig config, TemplateManager templateManager, String baseDirectory, String outputDirectory, String pluginDirectory, String templateDirectory)
at Microsoft.DocAsCode.SubCommands.DocumentBuilderWrapper.BuildDocument()
Taking a look at docfx.exe.config
(in my DocFX installation's tools
folder), it contains an entry for System.Memory
:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
In the same folder, there is a System.Memory.dll
file, but its version is 4.6.31308.1
which is different from both the version shown in the config file (4.0.1.2
) and the one in the error message (4.0.1.1
). That seems like it could be problematic...?
Removing the plugins/memberpage.2.59.4/content
entry in the docfx.json
's template section allows me to build without errors, but that's obviously not a solution.
I've now reverted to v2.59.0 (I was previously using v2.59.4) of both docfx and the memberpage plugin, and I'm no longer getting the error. I skimmed through the commits that happened between those versions and didn't notice anything out of place, but I also have no idea what I'm looking for—hopefully someone more familiar with docfx can figure something out 🙂
In the same folder, there is a System.Memory.dll file, but its version is 4.6.31308.1
And the latest nuget packages says version 4.5.5. That System.Memory.dll
is quite a problem area not restricted to DocFX.
https://developercommunity.visualstudio.com/t/systemmemorydll-version-mismatch-in-visual-studio/620823 https://developercommunity.visualstudio.com/t/systemmemorydll/244149 https://developercommunity.visualstudio.com/t/im-getting-build-error-systemmemorydll/237642 https://developercommunity.visualstudio.com/t/systemiofilenotfoundexception-could-not-load-assem/252454 https://developercommunity.visualstudio.com/t/xamarin-can-not-resolve-systemmemorydll-after-upgr/236347
No idea how DocFX loads plugins, but looking at the Fusion logs, I see that
docfx.exe
executable loads System.Memory v 4.0.1.2 from its own directoy, trusting docfx.exe.config
binding redirectsdocfx.console\2.59.4\tools\plugins_b0lynfaw.gys\plugins\docfx.plugins.config
config file and not docfx.exe
own binding redirects.Patching memberpage/2.59.4/content/plugins/docfx.plugins.config
to add the System.Memory binding redirect, and then it works. Have created this issue (https://github.com/dotnet/docfx/issues/8205) specifically for MemberPage.
Operating System: Windows 11
DocFX Version Used: v2.58.9
Template used: (
default
orstatictoc
or contain custom template)Steps to Reproduce:
Expected Behavior:
docfx should build the local repo
Actual Behavior:
Error Below : Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)