After deploying a WebApplication which uses the LeadTools 20 DocumentConverter, the application gave me the following exception trying to load my document from a memory stream:
System.TypeInitializationException: Der Typeninitialisierer für "
" hat eine Ausnahme verursacht. ---> .ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
---> System.Runtime.Serialization.SerializationException: Die Assembly "System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" kann nicht gefunden werden.Server stack trace:
bei System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
bei System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
bei 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)
bei System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
bei System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
bei System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
bei System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
bei System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain()
bei System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
bei System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
bei System.AppDomain.get_Id()
bei
.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
bei .LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* )
bei .LanguageSupport._Initialize(LanguageSupport* )
bei .LanguageSupport.Initialize(LanguageSupport* )
--- Ende der internen Ausnahmestapelüberwachung ---
bei .ThrowModuleLoadException(String errorMessage, Exception innerException)
bei .LanguageSupport.Initialize(LanguageSupport* )
bei .cctor()
--- Ende der internen Ausnahmestapelüberwachung ---
bei Leadtools.Document.DocumentFactory.ILcmYy3nX(LoadDocumentData , Exception )
bei Leadtools.Document.DocumentFactory.q3UxSnGHl(Uri , String , Stream , LoadDocumentOptions , Boolean )
bei Leadtools.Document.DocumentFactory.LoadFromStream(Stream stream, LoadDocumentOptions options)How-i-fixed-it:I fixed it by adding the
System.Diagnostics.DiagnosticSource.dll to the GAC, using an admin command prompt
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.3
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
\bin>gacutil -i System.Diagnostics.DiagnosticSource.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.Die Assembly wurde dem Cache erfolgreich hinzugefügt.
\DocumentConverter\DocumentConverter\bin>iisreset
I also found how to install an assembly to GAC:
https://stackoverflow.com/questions/9726035/where-can-i-find-gacutil