Showing posts with label GAC. Show all posts
Showing posts with label GAC. Show all posts

Friday, May 10, 2019

LEADTOOLS DocumentConverter IIS Exception 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.

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

Friday, July 5, 2013

SQLCLR error: Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)


I was referencing the "System.Drawing" DLL (Version 2.0.0.0) in my SQLCLR Assembly Project.
It was running fine for ages on the Server until i deployed a new version of my Assembly to it today:
Error message when you execute a CLR routine or use an assembly in SQL Server: "Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)"

How-i-fixed-it:
I was able to fix my problem by executing this T-SQL command on my database:

Alter Assembly [System.Drawing]
From 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll'

The issue is also discussed here:
http://social.technet.microsoft.com/Forums/sqlserver/en-US/17df0715-7608-480d-8ad6-78dcf6c9d43a/different-version-in-gac-and-SQL

Link to Microsoft Knowledge Base Article:
http://support.microsoft.com/kb/949080