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

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.

Related

AWS CDK - How do you fix the "Fatal process OOM in insufficient memory to create an Isolate" error?

I am trying to work some examples with the AWS CDK using C# as the language. My platform is Windows 10. Edit: I forgot to mention, I'm using a 64-bit Windows 10 and I have 16 GB of RAM.
I've followed the Getting Started instructions here: Getting Started With the AWS CDK, including making sure I have all the prerequisites.
I can create a project just fine, but when I try to use synth or deploy, it get the following:
Unhandled exception. Amazon.JSII.Runtime.JsiiException: Child process exited unexpectedly:
#
# Fatal process OOM in insufficient memory to create an Isolate
#
at Amazon.JSII.Runtime.Services.Runtime.ReadResponse()
at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
at Amazon.JSII.Runtime.Services.Client.Hello()
at Amazon.JSII.Runtime.Services.ServiceContainer.BuildServiceProvider(ILoggerFactory loggerFactoryOverride)
at Amazon.JSII.Runtime.Services.ServiceContainer.<>c.<.cctor>b__8_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Amazon.JSII.Runtime.Services.ServiceContainer.get_ServiceProvider()
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase.Load(Assembly assembly)
at Amazon.JSII.Runtime.Deputy.JsiiTypeAttributeBase..ctor(Type nativeType, String fullyQualifiedName)
at Amazon.JSII.Runtime.Deputy.JsiiClassAttribute..ctor(Type nativeType, String fullyQualifiedName, String parametersJson)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
at Amazon.JSII.Runtime.ReflectionUtils.GetClassAttribute(Type type)
at Amazon.JSII.Runtime.Deputy.DeputyBase..ctor(DeputyProps props)
at Amazon.CDK.Construct..ctor(DeputyProps props)
at Amazon.CDK.App..ctor(IAppProps props)
at CdkHello.Program.Main(String[] args) in C:\VSTS\Sandbox\Hampson\cdk-hello\src\CdkHello\Program.cs:line 12
Subprocess exited with error 3762504530
Program.cs, line 12 is a generated line, unchanged from it's initial form.
I have searched repeatedly for this error, and all the search results point to node.js. But none of the solutions (all involving some form of setting max-old-space-size) work to clear this for me. As far as I can tell, all my Node and JS installs, as well as the CDK install are up to date.
I can repeatedly duplicate this by creating a new project, then trying to run synth or deploy on it:
cdk init app --language csharp
cdk synth
I've been struggling with this for several days and have no more ideas. Any suggestions would be welcome.

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.

ServiceStack: Deployment causes FileLoadException, can't load System.Runtime.Serialization

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.

SerializationException using VS 2008 Addin: not find assemby

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.

Why is Assembly.GetCustomAttributes suddenly throwing TypeLoadException on build machine with Silverlight 4?

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.

Categories

Resources