SerializationException using VS 2008 Addin: not find assemby - c#

I'm writing a Visual Studio 2008 add-in and all was working fine, but few days, sometimes, there are strange errors about Serialization (unable to find assembly).
My addins compile work, and runtime too.
When open new instance Visual Studio, my addin fails when click menu option.
but then if open solution all works (few sometimes fails)
code:
private void AbrirFicheroMfa()
{
using (Stream containerStream = File.OpenRead(this.FicheroMFA))
{
mfaContainer = this.Deserialize(containerStream);
containerStream.Close();
}
}
public MfaContainer Deserialize(Stream serializationStream)
{
var formatter = new BinaryFormatter();
return (MfaContainer)formatter.Deserialize(serializationStream);
}
error:
Error al abrir Mfa en VisorMfa: Unable
to find assembly
'COMPANY.LifeCycle.Mfa,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=9744987c0853bf9e'.
Tipo:
System.Runtime.Serialization.SerializationException
Mensaje: Unable to find assembly
'COMPANY.LifeCycle.Mfa,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=9744987c0853bf9e'.
StackTrace:
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.ObjectMap.Create(String
name, 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.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream)
at
COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.Deserialize(Stream
serializationStream) in
E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line
139
at
COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.AbrirFicheroMfa()
in
E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line
131
at
COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.FrmICSharpCode_Load(Object
sender, EventArgs e) in
E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line
72
any suggestions ?
update:
once I get this error:
SerializationException:
[A]COMPANY.LifeCycle.Mfa.MfaContainer
cannot be cast to
[B]COMPANY.LifeCycle.Mfa.MfaContainer.
Type A originates from
'COMPANY.LifeCycle.Mfa,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null' in the context
'LoadFrom' at location
'C:\Projects\Addins\Mfa\COMPANY.LifeCycle.Mfa.dll'.
Type B originates from
'COMPANY.LifeCycle.Mfa,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null' in the context
'LoadNeither' at location
'C:\Documents and Settings\eprados\ConfiguraciĆ³n local\Datos de programa\Microsoft\VisualStudio\9.0\ProjectAssemblies\wi3h64z601\COMPANY.LifeCycle.Mfa.dll'.
I have an WinForms application and all is work. Serialization is ok.
For VS Addin, I have:
Addin.dll references
ComunDespliegue.dll and
LifeCycle.Mfa.dll
ComunDespliegue.dll references
LifeCycle.Mfa.dll
For WinForms app, I have:
UI.Client.dll references
ComunDespliegue.dll and
LifeCycle.Mfa.dll
The assembly reside in the addin directory alongside my addin. the type i'm serializing is serializable. The COMPANY.LifeCycle.Mfa.dll is the same.

Use Fuslogvw.exe to find out where the CLR looked for the assembly. There are two basic reasons. First is that you incremented the [AssemblyVersion] of the assembly in a recent update and are trying to deserialize data that was saved with the old version of the assembly.
The second is that it simply cannot find the DLL. There are but a few places where you can store an assembly so that it can be found when VS is running. Either the GAC or the PrivateAssemblies or PublicAssemblies subdirectory of Visual Studio's Common7\IDE directory.

Related

Is there any alternative for Could not load file or Assembly except doing Update-Package -Reinstall?

I am switching between 2 branches, and in one branch I have added a new package, System.Collection.Immutable. When I switch back to the other branch, I always get,
Server Error in '/' Application.
Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/SomePath
LOG: Initial PrivatePath = C:\SomePath\bin
Calling assembly : Microsoft.CodeAnalysis.Workspaces, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\tret\dsdsdsdsd\web.config
LOG: Using host configuration file: C:\Users\user\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
[FileNotFoundException: Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount) +0
System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount) +162
System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +96
System.Reflection.CustomAttributeData..ctor(RuntimeModule scope, CustomAttributeRecord caRecord) +79
System.Reflection.CustomAttributeData.GetCustomAttributes(RuntimeModule module, Int32 tkTarget) +119
System.Reflection.CustomAttributeData.GetCustomAttributesInternal(RuntimeAssembly target) +83
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +226
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +68
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +89
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +30
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +165
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +37
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +584
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369
[HttpException (0x80004005): Could not load file or assembly 'System.Collections.Immutable, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724
And the only way I get my application back working is by running Update-Package -Reinstall which takes an hour or so.
Is there any alternative to this?

Is it possible to get out of this Nuget Hell scenario?

I want my project to have the following packages
Microsoft.Azure.ServiceBus
Microsoft.Azure.WebJobs.Extensions
Microsoft.Azure.WebJobs.Extensions.Storage
Microsoft.Azure.WebJobs.ServiceBus
Microsoft.NET.Sdk.Functions
.NETStandard Library
Newtonsoft.Json
Right now I have the most recent versions
Microsoft.Azure.ServiceBus (3.1.1)
Microsoft.Azure.WebJobs.Extensions (3.0.0)
Microsoft.Azure.WebJobs.Extensions.Storage (3.0.0)
Microsoft.Azure.WebJobs.ServiceBus (v3.0.0-beta8)
Microsoft.NET.Sdk.Functions (1.0.22)
.NETStandard Library (2.0.1)
Newtonsoft.Json(11.0.2)
Which have the following dependencies of WebJobs:
Microsoft.Azure.ServiceBus [None]
Microsoft.Azure.WebJobs.Extensions [Microsoft.Azure.WebJobs (>= 3.0.0)]
Microsoft.Azure.WebJobs.Extensions.Storage [Microsoft.Azure.WebJobs (>= 3.0.0)]
Microsoft.Azure.WebJobs.ServiceBus [Microsoft.Azure.WebJobs (= 2.2.0)]
Microsoft.NET.Sdk.Functions [Microsoft.Azure.WebJobs (>= 3.0.0 && < 3.1.0)]
.NETStandard Library [None]
Newtonsoft.Json [None]
Interestingly, Visual Studio isn't flagging this as a problem (no yellow triangles in Solution Explorer), even though there are clearly conflicting version requirements. When I try to build my Function App project I get the error
Severity Code Description Project File Line Suppression State
Error System.IO.FileNotFoundException: Could not load file or
assembly 'Microsoft.Azure.WebJobs, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified. File name: 'Microsoft.Azure.WebJobs,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' at
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken,
IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs,
Int32 methodInstCount, ObjectHandleOnStack type) at
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module,
Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext,
RuntimeTypeHandle[] methodInstantiationContext) at
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,
Type[] genericTypeArguments, Type[] genericMethodArguments) at
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord
caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly,
RuntimeModule decoratedModule, MetadataToken decoratedToken,
RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[]
attributes, IList derivedAttributes, RuntimeType& attributeType,
IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean&
isVarArg) at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount,
RuntimeType attributeFilterType, Boolean mustBeInheritable, IList
derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeParameterInfo
parameter, RuntimeType caType) at
System.Attribute.InternalParamGetCustomAttributes(ParameterInfo param,
Type type, Boolean inherit) at
MakeFunctionJson.ParameterInfoExtensions.GetDisabledAttribute(ParameterInfo
parameterInfo) at
System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at
System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at
System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)
at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo
method) at
MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo
method, String& error) at
MakeFunctionJson.FunctionJsonConverter.<GenerateFunctions>d__9.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at
MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()
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].
Error generating functions metadata
Any way out of this Nuget Hell or can I not use all these packages? I've tried looking at previous versions and there seems to be no way to get them all to agree on a version of WebJobs. How does one typically resolve these situations?
Remove Microsoft.Azure.WebJobs.ServiceBus, the new package is now called Microsoft.Azure.WebJobs.Extensions.ServiceBus(3.0.0). See package references in v2 functions.
Besides, Microsoft.NET.Sdk.Functions(1.0.22) contains Newtonsoft.Json(11.0.2) and Microsoft.Azure.WebJobs.Extensions (3.0.0), no need to install them separately. And Microsoft.Azure.WebJobs.Extensions.ServiceBus(3.0.0) contains Microsoft.Azure.ServiceBus(3.0.2) as well, you don't need to install it either as long as the latest version is not necessary.
For example, you can create a v2 servicebus trigger template in VS and only need to add Microsoft.Azure.WebJobs.Extensions.Storage (3.0.0) to achieve your goal.

Load assembly in async Task asp.net

I run async Task which uses code from referenced DLL. In this case I cat error message that this referenced DLL can not be found.
Message: Unable to find assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
StackTrace: 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.ObjectMap.Create(String name, 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.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.AppDomain.Deserialize(Byte[] blob)
at System.AppDomain.UnmarshalObject(Byte[] blob)
If the code is in async Task then DLLs are taken from different location? Should I install it to GAC?
This is my web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
In Bin folder I have a Newtonsoft.Json.Dll, I run powershell script to check what is the version and it is:
[Reflection.AssemblyName]::GetAssemblyName('MyLocation\Newtonsoft.Json.DLL').Version
And the result is:
Major Minor Build Revision
----- ----- ----- --------
8 0 0 0
Then I wanted to check which assemblies are loaded into w3wp.exe process using listDlls.exe and there is:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xxx\Newtonsoft.Json.DLL
So I navigated there copied the dll and checked the version (just to be sure) and it is 8.0.0.0
I'm not sure what else can I do :D
I see that this is a cross domain serailization exception coming from
CrossAppDomainSerializer and this is used as Remoting
Infrastructure Sink for making calls across context boundaries
This is an issue originating from your code and remoting is done,please refer this SO post .
Hope this helps!

Could not load file or assembly System.Runtime.Serialization after publishing via Windows Azure

I published my solution using Windows Azure sdk and now I get this error:
Server Error in '/' Application.
Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' could not be loaded.
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].
Stack Trace: [FileNotFoundException: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +371
System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +19
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +319
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +203
System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable) +745
System.Reflection.CustomAttribute.IsDefined(RuntimeType type, RuntimeType caType, Boolean inherit) +300
System.ServiceModel.Description.TypeLoader.CreateMessageDescription(MethodInfo methodInfo, Boolean isAsync, Boolean isTask, Type taskTResult, XmlName returnValueName, String defaultNS, String action, XmlName wrapperName, String wrapperNamespace, MessageDirection direction) +415
System.ServiceModel.Description.TypeLoader.CreateOperationDescription(ContractDescription contractDescription, MethodInfo methodInfo, MessageDirection direction, ContractReflectionInfo reflectionInfo, ContractDescription declaringContract) +1895
System.ServiceModel.Description.TypeLoader.CreateOperationDescriptions(ContractDescription contractDescription, ContractReflectionInfo reflectionInfo, Type contractToGetMethodsFrom, ContractDescription declaringContract, MessageDirection direction) +276
System.ServiceModel.Description.TypeLoader.CreateContractDescription(ServiceContractAttribute contractAttr, Type contractType, Type serviceType, ContractReflectionInfo& reflectionInfo, Object serviceImplementation) +1307
System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) +289
System.ServiceModel.Description.ContractDescription.GetContract(Type contractType, Type serviceType) +192
System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts) +591
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +166
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +474
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +42
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +569
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1435
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +76
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +901
[ServiceActivationException: The service '/CarManagerApi.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified..]
System.Runtime.AsyncResult.End(IAsyncResult result) +622882
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +196075
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +282
I can't find the error in the code.
What is the problem?
My problem was different .Net frameworks in projects on the same solution
Sounds like the framework 2.0 isn't installed on remote machine.
I ran into this problem using Newtonsoft.Json in a library. The library worked fine on Windows, but died with this error when used with Mono on OS X.
In order to get it to run I had to copy the actual System.Runtime.Serialization.dll into the application directory.
Obviously it's not a great solution but it works.

IIS8: Could not load type 'System.ServiceModel.Activation.HttpModule'

There are lots of questions answering this, but none of the answers are working for me.
Originally, I was getting a 405 when I was trying to PUT or DELETE (probably other verbs too). Looking at some questions, the solution seemed to be to change the Handler Mappings.
I changed the following:
ExtensionlessUrlHandler-ISAPI-4.0_32bit
ExtensionlessUrlHandler-ISAPI-4.0_64bit
WebDAV
I noticed that the verbs were already in the One of the following verbs box, so in desperation I changed it to accept all verbs.
Now, I can't even load the webpage, let alone make any exotic requests like a DELETE, I immediately get a yellow screen of death:
Server Error in '/' Application.
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +100
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76
[ConfigurationErrorsException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12687536
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +66
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +300
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18045
So far I have:
Checked ASP.NET 4.5 is installed via Web PI
Running dism /online /enable-feature /featurename:IIS-ASPNET45
Running "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
Running C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -I
More iisresets than I can could
Replacing the ServiceModel in the applicationHost.config:
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
replaced with:
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv4.0" />
What else can I do, or where should I be looking?
Thanks
Dave
you also have to activate servicemodel 4.0 with
dism /online /enable-Feature /all /FeatureName:WCF-HTTP-Activation45
and in de IIS manager (server -> feature -> modules)
check if you see servicemodel 4.0 and then remove servicemodel.
I had the same problem after installing Synfusion Essential Studio on my computer.
I resolved by performing the following steps:
Open IIS Manager console
On the Server panel go to Modules, features view
Make sure ServiceModule-4.0 is there. If it's not there, perform the steps prescribed above (1-6)
Remove ServiceModel module
Just thought this might help someone.
This error can occur when there are multiple versions of the .NET Framework on the computer that is running IIS, and IIS was installed after .NET Framework 4.0 or before the Service Model in Windows Communication Foundation was registered.
here is the link to resolve this.
http://msdn.microsoft.com/en-us/library/hh169179%28v=nav.71%29.aspx
This link works for me.
http://www.codeproject.com/Articles/613812/Solve-IIS-Error-Could-not-load-type-System-Servi
You have to remove the ServerModel module and the svc-integrated handler.
Adding this to my application's web.config worked for me:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ServiceModel-4.0" type="System.ServiceModel.Activation.ServiceHttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
</modules>
</system.webServer>

Categories

Resources