Void System.Threading.Monitor.Enter Error when using ILMerge - c#

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

Related

Getting ModuleLoadException (C++ Modules) and TypeLoadException from WindowsBase.DLL ONLY when attempting to use the System.Windows.Clipboard class?

I am running a C# WinForms app. The goal of this small section of code is to copy the contents of a .JMP file into a .csv file for data manipulation. Easy enough right? I do not want to do this all in JMP or using a .jsl. The code for parsing and reformatting the data is already there for .csv files and has been working flawlessly.
The app that runs fine unless I have this one specific line that accesses the System.Windows.Clipboard class in my code:
Clipboard.SetDataObject(my data);
When I run the code with the line commented out all is well, but when I run them with the line included the app immediately goes into breakmode with these exceptions:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for '<Module>' threw an exception.
Source=<Cannot evaluate the exception source>
StackTrace: Cannot evaluate the exception stack trace
Inner Exception 1:
ModuleLoadException: The C++ module failed to load during appdomain initialization.
Inner Exception 2:
TypeLoadException: Could not load type 'System.Windows.Media.DisableDpiAwarenessAttribute' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
For Inner Exception 1, I am confused because this is a C# app in WinForms with no C++, don't know what the deal is here.
For Inner Exception 2, I am confused because the Assembly WindowsBase is for WPF and not WinForms. I am unable to even add a project reference to this WindowsBase assembly. Again, these errors only happen when I try to do anything with the System.Windows.Clipboard class.
I have downloaded, installed, and ensured the proper location of the following DLLs:
1. PresentationCore.dll
2. System.Windows.Forms.dll
Am I still missing some DLLs? Any help is appreciated.
You should use System.Windows.Forms.Clipboard instead of System.Windows.Clipboard, for the latter one is from WPF. You should remove the reference to PresentationCore.dll, because it's from WPF and not needed in WinForm.

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.

Why is it actually impossible to load onnxruntime.dll?

Using the tutorial from the developers at Microsoft, I followed the tutorial created at https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/object-detection-onnx.
I made sure to install CUDA V10.1.243 and cuDNN 7.6.5 from Nvidia's site.
Yet somehow, even after copying the entire contents of C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin to my project binary's directory at machinelearning-samples\samples\csharp\end-to-end-apps\ObjectDetection-Onnx\OnnxObjectDetectionApp\bin\Debug\netcoreapp3.0, I keep running into the following error while compiling the example program MS provided: Exception thrown: 'System.DllNotFoundException' in System.Private.CoreLib.dll An exception of type 'System.DllNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E).
This should make sure they are accessible from the PATH right? I'm also including their original location in NVIDIA GPU Toolkit in the system PATH as well. I am using the latest version of Visual Studio 2019 to load and compile this solution. Is there anyone out there that has been able to run this code successfully, and if so, how?

PostSharp OutOfMemoryException during Visual Studio build

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.

C# opengl texture

I want to use textures in opengl on my C# application.
I'm using the Tao Framework and I used this code
http://www.gamedev.net/community/for...opic_id=405453 (post #2)
But I got this runtime error:
An unhandled exception of type 'System.DllNotFoundException' occurred in WindowsFormsApplication1.exe
Additional information: Unable to load DLL 'DevIL.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Could someone help me?
Is there any other way to do this?
I had this problem with GLU.FreeGLUT.dll but when I installed Tao Framework solved my problem .
before that i copy dll to win32 and there was in dotnet Directory and add to references in project but I recieved this message : "An unhandled exception of type 'System.DllNotFoundException' "
It looks like the problem is the loading of the dll. You should make sure the dll is properly importer in your project through the references. Also make sure that you haven't moved or deleted the dll after you have added it to your project.
It suggests you are missing DevIL. Try getting it and installing it before proceeding.

Categories

Resources