Info: Could not load file or assembly ‘PortableEngine, Version=…'
Announcement made by Cem Alacayir - June 19, 2017 at 2:57 AM
Employee Post
If you see this error when you try to view a document with DocumentViewer (the yellow highlighted places can be different for different DocumentUltimate versions):
 
The type initializer for '_UyH' threw an exception. 
---> Could not load file or assembly 'PortableEngine, Version=2.7.4.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038' or one of its dependencies. The system cannot find the file specified.
 
You probably have
 
  1. Application Insights in your project. It’s a bug of System.Diagnostics.DiagnosticSource 4.4.0 or 4.4.1 which Application Insights installs as a dependency, this is described here:
    https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/613

    Removing Application Insights and all dependencies would fix the problem, however they fixed System.Diagnostics.DiagnosticSource after 4.5.0-preview2-25621-02 version so update this package in your project to the latest preview version from here to fix the problem without needing to remove Application Insights:
    https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Diagnostics.DiagnosticSource
     
  2. Glimpse in your project and this is a side-effect of Glimpse.
    Update: After DocumentUltimate v3.6.0 (October 12, 2017), this side-effect is prevented internally and you do not need the below workaround for Glimpse.

    For fixing it; add this setting to your web.config:
     
    <appSettings>
    	<add key="Glimpse:DisableAsyncSupport" value="true" />
    </appSettings>
     
 
If you don't have one of the above, find AssemblyResolver.log for more details on why assembly loading may have failed (yellow highlighted folder names will be different, if you are not sure which folder it is, just go to parent folder and search for AssemblyResolver.log):
 
  • If you were running on IIS, go to folder:
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\APPNAME\fb52cde5\AssemblyUltimate\

    If IIS worker process is running in 32-bit mode (when "Enable 32-bit applications" option is checked for the application pool), go to folder:
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\APPNAME\fb52cde5\AssemblyUltimate\
  • If you were running on Visual Studio, go to folder:
    %UserProfile%\AppData\Local\Temp\Temporary ASP.NET Files\vs\f3617516\AssemblyUltimate
     
  • If you were running on an Azure WebApp, go to folder:
     
    d:\home\GleamTech\AssemblyUltimate
    After DocumentUltimate v3.7.0 (or FileUltimate v5.15.0), temporary files will be stored under d:\home\GleamTech\ so that you can easily access them from Kudu Console (Azure Advanced Tools).
     
Sample error in the log caused by Application Insights:
Received AssemblyResolve event -> Failed resolving assembly:
  Assembly Name:
  GraphicsEngine, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038
  Requesting Assembly:
  <unknown>
  Error:
  System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> _Q0: The C++ module failed to load while attempting to initialize the default appdomain.
   ---> System.Runtime.Serialization.SerializationException: Unable to find assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
  
  Server stack trace: 
	 at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
	 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
	 at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
	 at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
	 at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
	 at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
	 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
	 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
	 at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
	 at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain()
	 at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
	 at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)
 
Sample error in the log caused by Glimpse:
Received AssemblyResolve event -> Failed resolving assembly:
 Assembly Name:
 PortableEngine, Version=2.7.1.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038
 Requesting Assembly:
 <unknown>
 Error:
 System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> _fXg: The C++ module failed to load while attempting to initialize the default appdomain.
  ---> System.NotSupportedException: Some environments conflict with current Glimpse async support. Please set Glimpse:DisableAsyncSupport = true in Web.config, or see https://github.com/Glimpse/Glimpse/issues/632 for more details.
 
 Server stack trace: 
	at Glimpse.AspNet.AspNetFrameworkProvider.AntiSerializationWrapper`1.GetObjectData(SerializationInfo info, StreamingContext context)
	at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
	at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
	at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
	at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
	at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize)
	at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage..ctor(IMethodCallMessage mcm)
	at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.SmuggleIfPossible(IMessage msg)
	at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)
 

6 Replies

Reply to Thread
0
Hi, I'm experiencing the same issue but only after deploying to Azure, it works fine in the development environment. I'm not sure how or if I can even access the AssemblyResolver.log either. Is this something we must install on Azure before we can use it? Thanks
0
FYI, DocumentUltimate v3.6.0 (October 12, 2017) fixes this error:
 

Fixed: The below error which happened in some environments:

The type initializer for '_UXg' threw an exception. ---> Could not load file or assembly 'PortableEngine, Version=2.7.3.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038' or one of its dependencies.

The error happened either:

  • When ASP.NET impersonation was used via <identity impersonate="true" /> tag in web.config

  • When Glimpse library (diagnostics & insights library) was used in the project.

In both cases, the error is now fixed.

So you should not need the above workarounds.

0
I'm seeing a similar error with DocumentUltimate 3.8 and System.Diagnostics.DiagnosticSource 4.4.1:
 
[2.1.2018 10.51.05] [Error]        : Received AssemblyResolve event -> Failed resolving assembly:
                                     Assembly Name:
                                     PortableEngine, Version=2.7.5.0, Culture=neutral, PublicKeyToken=a6f3cafa178e6038
                                     Requesting Assembly:
                                     <unknown>
                                     Error:
                                     System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> _ReH: The C++ module failed to load while attempting to initialize the default appdomain.
                                      ---> System.Runtime.Serialization.SerializationException: Unable to find assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
                                     
                                     Server stack trace: 
                                        at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
                                        at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
                                        at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
                                        at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
                                        at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
                                        at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
                                        at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
                                        at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
                                        at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
                                        at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain()
                                        at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
                                        at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)
                                     
                                     Exception rethrown at [0]: 
                                        at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
                                        at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
                                        at System.AppDomain.get_Id()
                                        at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
                                        at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(_Rhi* )
                                        at <CrtImplementationDetails>.LanguageSupport._Initialize(_Rhi* )
                                        at <CrtImplementationDetails>.LanguageSupport.Initialize(_Rhi* )
                                        --- End of inner exception stack trace ---
                                        at <CrtImplementationDetails>.LanguageSupport.Initialize(_Rhi* )
                                        at .cctor()
                                        --- End of inner exception stack trace ---
                                        at System.Runtime.CompilerServices.RuntimeHelpers._RunModuleConstructor(RuntimeModule module)
                                        at GleamTech.AssemblyResolver.AssemblyResolver.RunModuleInitializer(Assembly assembly)
                                        at GleamTech.AssemblyResolver.AssemblyResolver.LoadAssembly(MergedAssembly mergedAssembly)
                                        at GleamTech.AssemblyResolver.AssemblyResolver.OnAssemblyResolve(Object sender, ResolveEventArgs args)
 
0
Yes, it’s a bug of System.Diagnostics.DiagnosticSource 4.4.1 which “Application Insights” installs as a dependency. However they fixed it after 4.5.0-preview2-25621-02 version so update that package in your project to the latest preview version from here:
https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.Diagnostics.DiagnosticSource
0
Aha, thanks. I thought they had fixed it in 4.4.1, but that's probably just me misreading the comments in the issues.
0
Yes, the bug happens with 4.4.0 or the last one 4.4.1 on nuget.org. So you need the latest 4.5.0-preview2 from dotnet.myget.org, it's not published to nuget.org yet.

Reply to Thread