Repository navigation
StackExchange.Precompiler.exe throws reference errors #33
Copy link
Copy link
Open
Description
I'm not normally one for posting huge blocks of code.
But the 4.0.0 StackExchange.Precompiler.exe throws this when I try to run it.
ERROR: An unhandled exception occured
System.IO.FileNotFoundException: Could not load file or assembly 'System.Composition.AttributedModel, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Composition.AttributedModel, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at StackExchange.Precompilation.CompilationAssemblyResolver.<>c__DisplayClass3_0.<Setup>b__4(String resourceKey) in C:\projects\stackexchange-precompilation\StackExchange.Precompilation.Build\CompilationAssemblyResolver.cs:line 51
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.Tasks.Task.Execute()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
System.IO.FileNotFoundException: Could not load file or assembly 'System.Composition.TypedParts, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Composition.TypedParts, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at StackExchange.Precompilation.CompilationAssemblyResolver.<>c__DisplayClass3_0.<Setup>b__4(String resourceKey) in C:\projects\stackexchange-precompilation\StackExchange.Precompilation.Build\CompilationAssemblyResolver.cs:line 51
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.Tasks.Task.Execute()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
System.IO.FileNotFoundException: Could not load file or assembly 'System.Composition.Hosting, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Composition.Hosting, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at StackExchange.Precompilation.CompilationAssemblyResolver.<>c__DisplayClass3_0.<Setup>b__4(String resourceKey) in C:\projects\stackexchange-precompilation\StackExchange.Precompilation.Build\CompilationAssemblyResolver.cs:line 51
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.Tasks.Task.Execute()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
System.IO.FileNotFoundException: Could not load file or assembly 'System.Composition.Runtime, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Composition.Runtime, Version=1.0.30.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
at System.Reflection.Assembly.Load(Byte[] rawAssembly)
at StackExchange.Precompilation.CompilationAssemblyResolver.<>c__DisplayClass3_0.<Setup>b__4(String resourceKey) in C:\projects\stackexchange-precompilation\StackExchange.Precompilation.Build\CompilationAssemblyResolver.cs:line 51
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.Tasks.Task.Execute()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].```
Reacted by Tom Pažourek
Metadata
Metadata
Assignees
Labels
No labels
Activity
itssimple commentedon Aug 8, 2017
I got it to work by adding these DLLs manually to the tools folder:
I found which versions by looking into
StackExchange.Precompiler.exe.configitssimple commentedon Aug 9, 2017
Doesn't work at AppVeyor though
https://ci.appveyor.com/project/itssimple/mn-l10n/build/1.0.65#L1455
itssimple commentedon Aug 9, 2017
Fix for AppVeyor
I ran this in the Install Script-section:
And then I modified the config-file to support version 1.0.31 of the
System.Composition.*packagesAnd in Before build-script I run:
copy StackExchange.Precompilation.Build.cfg C:\Users\appveyor\.nuget\packages\stackexchange.precompilation.build\4.0.0\tools\StackExchange.Precompiler.exe.config /Ytompazourek commentedon Oct 6, 2017
I have the same issue (running 4.1.1 version).
I suspect the main problem is that I have more references to the same assemblies and they aren't resolved correctly -- I'm using .NET Framework, and some projects reference the .NET Framework "System.Runtime" (which is assembly version 4.0.20.0 in .NET 4.7 on path
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\Facades\System.Runtime.dll), while some libraries that are built for .NET Standard use the NuGet's "System.Runtime" package (e.g. assembly version "4.1.1.0" of package "4.3.0" on pathpackages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll).The precompiler isn't then able to resolve this correctly. It crashes on an exception like:
I solved the issue the same way as @itssimple, I added those lines to my Cake build script (right after NuGet package restore):
m0sa commentedon Oct 6, 2017
That sounds familiar. I've had this happen in another project, which doesn't use SE Precompilation. Did you try setting
DependsOnNETStandardto true?Can you try building with
/property:SEPrecompilerSkip=true? This would cause a build with the stockcsc.exe; I wonder if it knows how to handle the different versions?tompazourek commentedon Oct 9, 2017
I made some progress since, I've updated to .NET 4.7 (from .NET 4.6.1) and to VS 2017 (and MSBuild 15). Then it seems that most of these assemblies resolve correctly just based on the binding redirects to the .NET 4.7 assembly, not the assembly from NuGet. I've also done some NuGet package reinstallations...
So most of this copying of assemblies was no longer needed. However, there was an exception to this. There was a problem with assemblies that are found in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net47\ref(noticeref)There are just 3 assemblies there:
When compiling with the
SEPrecompilerSkipproperty on, the precompilation is skipped and the build is fine (even no warnings about any assembly versions). However, when I execute the precompilation, the precompiler complains that itCannot load a reference assembly for executionand mentions one of these.I have tried several things and the only reliable way to get around this issue without causing additional issues during build or runtime, was to copy the three assemblies from:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net47\lib(noticelib) to folder with the precompiler executable. That made it work for me.