PostSharp OutOfMemoryException during Visual Studio build - c#

I'm using the latest version of PostSharp (version 4.1.31.0) in a C# solution with Visual Studio 2015 (with update 1).
Everytime I try to build the solution I get the following error:
Unhandled exception (4.1.31.0, postsharp.srv.4.0-x86.exe, CLR 4.0.30319.394271, Release): System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
I've switched on detailed output when building but haven't been able to spot anything in the output so far!
I have other solutions that work fine with this version so I suspect it is something to do with the solution's configuration.
As an aside, I have also tried version 4.1.30 and get exactly the same error.
Any help or advice on where to look would be greatly appreciated.

So to solve my issue all I had to do was to set the PostSharp 'Processor Architecture' option in the project properties to x64 for the project that includes my aspects.
I'm not exactly sure why but my application builds and runs without issues.

Had the same issue, PostSharp crashing at compile time:
Severity Code Description Project File Line Suppression State
Error An unexpected exception occurred when executing user code: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at PostSharp.Patterns.Model.NotifyPropertyChanged.DependencyAnalysis.InpcMemberAnalysis.IsInpcIgnoredProperty(PropertyInfo property)
at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.<>c.<GetNotifiableProperties>b__48_0(PropertyInfo p)
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.GetNotifiableProperties(Type type, Boolean excludeExplicitProperties, Boolean& hasExplicitProperties)
at PostSharp.Patterns.Model.NotifyPropertyChangedAttribute.CompileTimeInitialize(Type type, AspectInfo aspectInfo)
at PostSharp.Sdk.AspectWeaver.AspectWeavers.TypeLevelAspectWeaverInstance.^gAHJKdyo.^WnalpwzH()
at PostSharp.Sdk.Utilities.ExceptionHelper.ExecuteUserCode(MessageLocation messageLocation, Action userCode, Type[] acceptableExceptions). Avalon.Dock.Measurements
Solved it by killing the process PostSharp Compile service (something like this) from the task manager.

Related

Blazor linking error: Value cannot be null. (Parameter 'input')

I have spent some weeks to create a prototype for my customer using the Blazor Webassembly hosting model. It has worked far above my expectations. Until now. Time for first deployment to real environment on Azure. I have configured PublishTrimmed=true in client and server project files. Is that needed in both projects?
Unfortunately the publish failed on the linking giving me these two errors:
"Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false."
"IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues"
In the dialog I am referred to a tmp file having this content:
"System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details."
The output window includes this section:
Fatal error in IL Linker
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'input')
at System.Text.RegularExpressions.ThrowHelper.ThrowArgumentNullException(ExceptionArgument arg)
at System.Text.RegularExpressions.Regex.Matches(String input)
at Mono.Linker.Steps.MarkStep.MarkTypeWithDebuggerDisplayAttribute(TypeDefinition type, CustomAttribute attribute)
at Mono.Linker.Steps.MarkStep.MarkTypeSpecialCustomAttributes(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet1 typesAlreadyVisited) at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet1 typesAlreadyVisited)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
What can I do? I have really recommended Blazor to my colleagues. I would be ashamed to tell them we need to skip the trimming and publish an application that will give the customers a download size of 9 MB!!!!
Is the trimming just an empty promise or does it actually work in real applications? Can I do something to detect the crucial problem? The error hints are not really helpful. I don't mind reporting an issue, but I have no meaningful details to include in the report.

Failed to resolve for reference Microsoft.Azure.WebJobs.Extensions - Metadata generation failed

Had to pick up a bit of work from another developer so just trying to wrap my head round it all!
But I'm having issues building an Azure Functions project and continuously getting a error coming form Microsoft.NET.Sdk.Functions.Build.targets , specifically unable to resolve a reference to Microsoft.Azure.WebJobs.Extensions.
So far I have attempted re-installing the Nuget Package, Re-Starting Visual Studio, my machine yada-yada.
I would welcome any suggestions and appreciate your time!
Full Error Below
Severity Code Description Project File Line Suppression State
Error Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.WebJobs.Extensions, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
at Mono.Cecil.TypeReference.Resolve()
at MakeFunctionJson.AttributeExtensions.IsWebJobsAttribute(CustomAttribute attribute)
at MakeFunctionJson.ParameterInfoExtensions.<>c.<IsWebJobSdkTriggerParameter>b__0_0(CustomAttribute a)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at MakeFunctionJson.ParameterInfoExtensions.IsWebJobSdkTriggerParameter(ParameterDefinition parameterInfo)
at MakeFunctionJson.MethodInfoExtensions.<>c.<HasTriggerAttribute>b__4_0(ParameterDefinition p)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at MakeFunctionJson.MethodInfoExtensions.HasTriggerAttribute(MethodDefinition method)
at MakeFunctionJson.MethodInfoExtensions.HasValidWebJobSdkTriggerAttribute(MethodDefinition method)
at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable`1 types)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()
Error generating functions metadata
Panmure.RiskMI.DataCollector.Functions
I saw a message when running the project saying "the extensionsmetadatagenerator package was not imported correctly" Try adding the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator nuget package to your project. It is suppose to be loaded as a dependency of Microsoft.NET.Sdk.Functions package, But I didn't see it in my project dependencies list. This worked for me.
Or you can just update to
<TargetFramework>netcoreapp3.1</TargetFramework>
If you are not on 3.1
I know this is an older post. I am using JetBrain Rider on a Mac. The only way I've gotten around this is to reinstall .Net 5 even though I am building the Function in .Net 6. Any updates that happen to .net 6 is requiring me to reinstall .net 5.

The "GenerateResource" task failed unexpectedly whit inner null reference exception

I'm making a Windows universal application 10, but when I build my solution, I've this error whit an inner exception.
The "GenerateResource" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.Tasks.ResGenDependencies.TryGetPortableLibraryInfo(String libraryPath)
at Microsoft.Build.Tasks.GenerateResource.GetResourcesToProcess(List1& inputsToProcess, List1& outputsToProcess, List`1& cachedOutputFiles)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
What does it mean? I've no information about whit file or line I had this.
I use Visual Studio Professional 2015.
Download and install the Visual Studio 2015 Update 1.
https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx
That solved the issue for me.

Void System.Threading.Monitor.Enter Error when using ILMerge

I'm trying to use ILMerge to combine my C# program with 3 referenced DLL's. If I run the program without merging them, everything runs well but when I merge them I get the "Void System.Threading.Monitor.Enter" Error.
Here are the DLL's I am combining:
HTMLAgilityPack.dll
MySql.Data.dll
RKLib.ExportData.dll
The error appears to be coming from the MySql.Data.dll but I am not really sure why it would throw this exception.
Any ideas much appreciated.
EDIT: Full error I am receiving is:
************** Exception Text **************
System.MissingMethodException: Method not found: 'Void System.Threading.Monitor.Enter(System.Object, Boolean ByRef)'.
at MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String value)
at MySql.Data.MySqlClient.MySqlConnection..ctor(String connectionString) in :line 0
What version of the framework are you using? There is a targetplatform option you may need to set if you are using 4.0/4.5 for example.
/targetplatform:version,platformdirectory

Ninject throw an exception while loading dependencies

After using my application successfully in development for a couple of weeks, I shipped it to my client. The application use Ninject to handle dependencies.
When I try to run the application on the client machine, an error occurs:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Ninject.Infrastructure.Language.ExtensionsForAssembly.HasNinjectModules(Assembly assembly)
at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
at Ninject.Modules.AssemblyNameRetriever+AssemblyChecker.GetAssemblyNames(System.Collections.Generic.IEnumerable`1<System.String>, System.Predicate`1<System.Reflection.Assembly>)
at Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(System.Collections.Generic.IEnumerable`1<System.String>, System.Predicate`1<System.Reflection.Assembly>)
at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(System.Collections.Generic.IEnumerable`1<System.String>)
at Ninject.Modules.ModuleLoader.LoadModules(System.Collections.Generic.IEnumerable`1<System.String>)
at Ninject.KernelBase..ctor(Ninject.Components.IComponentContainer, Ninject.INinjectSettings, Ninject.Modules.INinjectModule[])
at MyApplication.Main.Application_Start()
at MyApplication.Main..ctor()
at MyApplication.Program.Main()
What can cause this exception?
Framework 4.0
NInject 3.0.0.0
Thank you.
I would guess that the IoC container (Ninject) is looking for an assembly to reflect upon that cannot be found. Perhaps an assembly is not being packaged propely with your deployment? That could also explain why it works on your development machine but not on the client machine.

Categories

Resources