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

Error with running docfx on local #7832

Closed
niragvt opened this issue Jan 13, 2022 · 9 comments
Closed

Error with running docfx on local #7832

niragvt opened this issue Jan 13, 2022 · 9 comments
Labels
extensibility Extend the platform to support new languages, new outputs and custom behaviors fundamental Engineering system and core components

Comments

@niragvt
Copy link

niragvt commented Jan 13, 2022

Operating System: Windows 11

DocFX Version Used: v2.58.9

Template used: (default or statictoc or contain custom template)

Steps to Reproduce:

  1. Copy docfx folder, add it to path and then run docfx locally
  2. ex. docfx \docfx.json --serve

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)

image

@KalleOlaviNiemitalo
Copy link

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?

@todubble1
Copy link

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.

@saipramod
Copy link
Contributor

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

@jemayn
Copy link

jemayn commented May 19, 2022

Getting this as well on a fresh pc:

  • Downloaded DocFx via choco - v 2.59.2.0
  • Ran docfx metadata just fine
  • Get the error mentioned above on docfx build
  • My docfx.json had a reference to some postprocessors initially, tried removing them entirely and the issue persists

@ianceicys
Copy link

Getting this same error as well.

How do I find the plugin?

@tom-weiland
Copy link

tom-weiland commented Sep 16, 2022

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.

@tom-weiland
Copy link

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 🙂

@zpqrtbnk
Copy link

zpqrtbnk commented Oct 5, 2022

No idea how DocFX loads plugins, but looking at the Fusion logs, I see that

  • the docfx.exe executable loads System.Memory v 4.0.1.2 from its own directoy, trusting docfx.exe.config binding redirects
  • the MemberPage plugin tries to load System.Memory v 4.0.1.1 using a docfx.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 (#8205) specifically for MemberPage.

@yufeih yufeih added fundamental Engineering system and core components extensibility Extend the platform to support new languages, new outputs and custom behaviors labels Dec 15, 2022
@yufeih yufeih closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensibility Extend the platform to support new languages, new outputs and custom behaviors fundamental Engineering system and core components
Projects
None yet
Development

No branches or pull requests

10 participants