I've got a very simple ServiceStack service running, from a path /api/Translate/.... This works perfectly locally. I can view XML, JSON, etc.
However, when I deploy the project to the live environment, calling the service results in:
<TranslateResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
- <ResponseStatus>
<ErrorCode>FileLoadException</ErrorCode>
<Message>Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)</Message>
<StackTrace>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(RuntimeType type, RuntimeType caType, Boolean inherit) at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) at ServiceStack.WebHost.EndPoints.Utils.FilterAttributeCache.GetResponseFilterAttributes(Type responseDtoType) in C:\src\ServiceStack\src\ServiceStack\WebHost.EndPoints\Utils\FilterAttributeCache.cs:line 51 at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyResponseFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object responseDto) in C:\src\ServiceStack\src\ServiceStack\WebHost.EndPoints\EndpointHost.cs:line 205 at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:\src\ServiceStack\src\ServiceStack\WebHost.EndPoints\RestHandler.cs:line 64</StackTrace>
</ResponseStatus>
</TranslateResponse>
The TranslateResponse being my otherwise healthy DTO. The ResponseStatus is not mine. I have checked .NET version targetting and have set System.Runtime.Serialisation to "Copy Local" and manually included the DLL in the /bin folder.
But it still does not work. Where am I going wrong?
Solved it.
It was the inclusion of a Project built using the Portable Class Library project. That thing seemed too good to be true. Have removed (which solves other issues, chiefly MVVM implementation) and all works.
Related
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.
I need to switch a specific library that was from version 16.1 before to version 15.0. I did this by removing the higher version and installing the lower version by nuget.
When building, the correct dll (15.0) is created in the bin-directory. But I receive the following error when starting the (web) application:
[FileLoadException: Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
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) +145
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +158
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) +91
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +438
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +37
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +106
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +46
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +75
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +21
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
What is most irritating about this error is that the Owin-package seems to cause this error. But Owin should not have a reference to Microsoft.SharePoint.Client at all according to the NuGet-documentation.
Or is this whole strack trace misleading and Owin does not have to do anything with this problem?
I encountered the same problem. For me the problem got solved by removing the .dll that was causing the error from the bin directory. (In my case it was Microsoft.Online.Sharepoint.Tentant.dll)
I encountered the issue as well. It can be circumvented by specifying the startup class in the web.config, so that Owin does not try to search for the correct startup class.
The appSetting element overrides the OwinStartup attribute and
naming convention. You can have multiple startup classes (each using
an OwinStartup attribute) and configure which startup class will be
loaded in a configuration file using markup similar to the following:
<appSettings>
<add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
</appSettings>
The following key, which explicitly specifies the startup class and
assembly can also be used:
<add key="owin:appStartup" value="StartupDemo.ProductionStartup, StartupDemo" />
Futher details can be found in the documentation.
I guess most of .NET devs have received a FileNotFoundException before and been awarded with this or similar view:
Most of the time, the stack trace looks something like this:
[FileNotFoundException: Could not load file or assembly 'Microsoft.WindowsAzure.Mobile.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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) +152
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +158
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) +91
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +438
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +37
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +106
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +46
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +75
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +21
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
Stack trace provides no hints to where in my own code the assembly is directly or indirectly referenced. It does say where in System/Microsoft assemblies it is referenced.
As I see it, the compiler is aware of what assemblies are 'my code' and what assemblies are System/Microsoft and third-party.
Q: Is there any way to determine the last line in 'my code' (like an extended stack trace) or is it made impossible for threading reasons or other shared memory issues ?
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.
A short while back i had to display the current version of our Silverlight app. After some googling the following code gave me the desired result:
var fileVersionAttributes = typeof(MyClass).Assembly.
GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false) as AssemblyFileVersionAttribute[];
var version = fileVersionAttributes[0].Version;
This worked a treat in our .NET 3.5 Silverlight 3 environment. However, we recently upgraded to .NET 4 and Silverlight 4. We just finished getting our build machine working and found that the unit test for this code was throwing the following exception:
Exception Message:
System.TypeLoadException: Error 0x80131522. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.0.50106.0&File=mscorrc.dll&Key=0x80131522
at System.ModuleHandle.ResolveType(ModuleHandle module, Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, Type caType)
at System.Reflection.Assembly.GetCustomAttributes(Type attributeType, Boolean inherit)
at MyCode.VersionTest()
I have never seen this exception before and the link in it points nowhere. It is only throwing on the build machine and not on my development box, so i'm going through a process of trial and error to see any differences between the two.
Any idea why this might be happening??
Cheers,
Andrej.
Usually you would see TypeLoadException when a Silverlight assembly has been linked to desktop libraries and one its types accesses a system type that is not supported on Silverlight.
I can't really explain why it broke under Silverlight 4, but my guess it's something inside your silverlight library. Can you execute the same code on one of system types and see if it crashes?
typeof(string).Assembly.
GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false) as AssemblyFileVersionAttribute[];
If the above doesn't crash, start commenting out bits of MyClass to see which part of it causes TypeLoadException.