AspNet Visual Studio - Error while merging assemblies

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 06:50:42

问题


This is occurring on visual studio 2019 community v 16.8.1 on a windows 10 PC.

I need help trying to find the cause for this error that happens at the end of publishing an asp.net 4.7 web project during the merge assemblies step.

"An error occurred when merging assemblies: Object reference not set to an instance of an object. "

The merge line looks like "D:\Repo\project\packages\Microsoft.AspNet.Merge.5.0.0-beta2\tools\net40\aspnet_merge.exe" "D:\Repo\project\obj\Release\AspnetCompileMerge\TempBuildDir" -o WebBuild -copyattrs obj\Release\AssemblyInfo\AssemblyInfo.dll -a

I added -errorstack to get this result

[NullReferenceException]: Object reference not set to an instance of an object.
   at System.Web.Compilation.WebCompilationVisitor.VisitMethodCall(MethodCall call)
   at System.Compiler.StandardVisitor.VisitExpression(Expression expression)
   at System.Compiler.StandardVisitor.VisitExpressionStatement(ExpressionStatement statement)
   at System.Compiler.StandardVisitor.VisitStatementList(StatementList statements)
   at System.Compiler.StandardVisitor.VisitBlock(Block block)
   at System.Compiler.StandardVisitor.VisitStatementList(StatementList statements)
   at System.Compiler.StandardVisitor.VisitBlock(Block block)
   at System.Compiler.StandardVisitor.VisitMethod(Method method)
   at System.Compiler.StandardVisitor.VisitMemberList(MemberList members)
   at System.Compiler.StandardVisitor.VisitTypeNode(TypeNode typeNode)
   at System.Web.Compilation.WebCompilationVisitor.VisitClass(Class Class)
   at System.Compiler.StandardVisitor.VisitTypeNodeList(TypeNodeList types)
   at System.Web.Compilation.WebCompilationVisitor.VisitTypeNodeList(TypeNodeList types)
   at System.Compiler.StandardVisitor.VisitModule(Module module)
   at System.Compiler.StandardVisitor.VisitAssembly(AssemblyNode assembly)
   at System.Web.Compilation.WebCompilationVisitor.VisitAssembly(AssemblyNode assembly)
   at ILMerging.ILMerge.Merge()
   at System.Web.Compilation.Merge.DoMerge(ILMerge merge)
   at System.Web.Compilation.Merge.MergeToSingleAssembly(String outputFile, String[] inputAssemblies, Hashtable assemblyMapping, DirectoryInfo inputDirectory, DirectoryInfo outputDirectory)
   at System.Web.Compilation.Merge.Main(String[] args)

But none of the above is telling me what the issue is.

I've tried updating to latest visual studio (2019 community v 16.8.1), I've removed visualstudio and vscommon folders from /local/microsoft. Restarted PC.

This issue started after the following windows update.

https://support.microsoft.com/en-gb/help/4586781/windows-10-update-kb4586781

Not sure if the update plays a part but I could publish fine prior to it. The update would have force quit visual studio.

Thanks Matt


回答1:


It seems that running the profiler had changed the web.config

<compilation debug="true" targetFramework="4.7.1" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

Cutting out assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from this tag

and removing

<dependentAssembly>
    <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <codeBase version="16.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL" />
</dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="VsWebSite.Interop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <codeBase version="8.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/VsWebSite.Interop.DLL" />
</dependentAssembly>

Allow the publish to work



来源:https://stackoverflow.com/questions/64815709/aspnet-visual-studio-error-while-merging-assemblies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!