Mono ThreadPool.QueueUserWorkItem() throws an error - c#

I just got a VPS server running Linux Debian 7 and tried to get one of my C# servers running on it using Mono. Unfortunately it did not work the first time i ran it, it threw this error:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.IAsyncStateMachine' from assembly 'mscorlib, Version=4.0.0.0
I've found out the exact line which is causing this error and it is:
ThreadPool.QueueUserWorkItem( myThread => TcpAccept() );
Without this line the server doesn't accept any connections and so on...
I would like to know how to fix this or find an alternative way to write this line. Any help is greatly appreciated!

Related

Web Assembly not compiling with linker error [Uno Platform]

So, I have been trying to compile a project in web assembly with Uno Platform, but I have not been able to successfully compile due to a linker error, This error is something like this:
Fatal error in Mono IL Linker
Mono.Linker.MarkException: Error processing method: 'System.Void Microsoft.Xaml.Interactivity.Behavior::.cctor()' in assembly: 'Microsoft.Xaml.Interactivity.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Uno.Diagnostics.Eventing.IEventProvider Uno.Diagnostics.Eventing.Tracing::Get(System.Guid)
I thought that maybe the Uno.Diagnostics.Eventing was missing or something, so, I've installed but after doing that the error persists.
I don't know what the error could be or if it is related to something else, anyone can give a hand?
Well, it seems that for my specific version of Uno.WebAssembly (3.0.17) I needed the package Uno.Microsoft.Xaml.Behaviors.Uwp.Managed to be on version 2.0.2-uno.79 to work. Simple as that

The "ParseILMergeInfoTask" task failed unexpectedly

The program is executing properly without any error in Debug configuration But in Release configuration it throws an error.
The "ParseILMergeInfoTask" task failed unexpectedly.
System.Exception: File 'SharedAssemblyILMergeInfoFilePath' passed to argument 'x86\ret\SharedAssemblyILMergeInfo.csv' does not exist.
at Microsoft.Build.ILTasks.ParseILMergeInfoTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
I can't run any program in Release configuration. It throws the same error.
Update
I think I found the problem but I don't know to resolve it. Previously I had an error Unable to load package 'Microsoft.Net.Native.SharedLibrary-x64'. To resolve it I follow it this answer. So I installed Microsoft.Net.Native.SharedLibrary-x64.1.6.1, Microsoft.Net.Native.SharedLibrary-x86.1.6.1 and Microsoft.Net.Native.SharedLibrary-arm.1.6.1 manually. Now If I open Microsoft.Net.Native.SharedLibrary-x64 package folder I can't find build and tools folder within it.
It is a problem due to the Internet connection.
Just delete the package
C:\Users\ponvi\.nuget\packages\microsoft.net.native.sharedlibrary-x64
Download the package using Mobile Data.
Another answer by rubStackOverflow
Really strange issue, in my case, I had to change my default network
DNS(network card) from 8.8.8.8 to 208.67.222.222.

Waiting for a file to change before restarting dotnet error

I am using asp.net core, razor engine, and entity framework. I am getting this error when I try to run my code in VS code using dotnet watch run. Here is the full error.
Project c-login (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
A JSON parsing exception occurred in [/Users/aaronmk2/Desktop/CodingDojo/c#/asp.net/entity/c-
login/bin/Debug/netcoreapp1.0/c-login.deps.json]: * Line 1, Column 2 Syntax error: Malformed
token
Error initializing the dependency resolver: An error occurred while parsing /Users/aaronmk2/D
esktop/CodingDojo/c#/asp.net/entity/c-login/bin/Debug/netcoreapp1.0/c-login.deps.json
[DotNetWatcher] fail: dotnet exit code: 139
[DotNetWatcher] info: Waiting for a file to change before restarting dotnet...
Has anyone seen this error before? What is the workaround?
I had the same error, after trying everything I figure out that it was because of the corrupted certificate. For some reason my certificate got corrupted so, I had to delete the old one and generate a new one.
To generate:
dotnet dev-certs https
To trust:
dotnet dev-certs https --trust
I think, you just have to successfully build your project and restart the server. It worked for me.
I received the same error but I had something else wrong. The issue that I had was that I was trying to connect to a server in my appsettings.json file using Microsoft credentials such as using Server=(LocalDB). After updating it to the MacOS way of connecting to a DB, it worked.
I went from
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=ShirtDB;Trusted_Connection=True;MultipleActiveResultSets=true"
To
"DefaultConnection": "Server=localhost,*port number*;Database=MyDB;User ID=sa;Password=******"
Although this was already solved I wanted to give another solution since I couldn't find much on this specific error.
I had a similar issue using MySQL that looked like this:
A JSON parsing exception occurred in [C:\foo\bin\Debug\netcoreapp3.1\foo.deps.json]: * Line 1, Column 2 Syntax error: Malformed token
Error initializing the dependency resolver: An error occurred while parsing: C:\foo\bin\Debug\netcoreapp3.1\foo.deps.json
I ended up dropping my schema and removing all my previous migrations and then it started working fine. My best theory is that something I did to my models caused it. Hopefully, this helps someone out.

Shader(Effect file) Crashing on Load

It worked just fine in the 3.5 stable version, but after upgrading to the lastest development branch (3.6), it no longer works, giving me this error on effect = content.Load<Effect>("fileName")
An unhandled exception of type 'SharpDX.SharpDXException' occurred in SharpDX.dll
Additional information: HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect.
Any help is immensely appreciated.
I got the same problem.
I think the default value has changed GraphicsProfile.
(HiDef -> Reach)
So if you specify it, it got it fixed.
Graphics.GraphicsProfile = GraphicsProfile.HiDef;

MonoDevelop: Semi cryptic error CS0016

Here's the error I'm getting:
Error CS0016: Could not write to file Fact.Apprentice.Core', cause: Type '<>__AnonType02' was not completed. (CS0016) (Fact.Apprentice.Core - Mono)
If I compile using MonoDevelop + Microsoft .NET, no such error shows up. When using Mono framework, I am unable to compile because of this. Behavior identical for Mac or PC installation.
This kind of error usually indicates compiler bug. The most likely source will be some of your LINQ queries. You could also try Mono 2.11 which should give you better error message.

Categories

Resources