Some problem when I newly downloaded dotnet and C# - c#

I recently tried to start c# and when I press 'dotnet run', vscode throws this type of error:
/home/user/HelloWorld/bin/Debug/net6.0/HelloWorld: relocation error: /home/user/HelloWorld/bin/Debug/net6.0/HelloWorld: symbol __pthread_key_create version GLIBC_2.2.5 not defined in file libpthread.so.0 with link time reference
Thanks in advance!

Did you installed Visual Studio-SDK and Runtime form snap?
If so, the easiest solution is to uninstall them using snap and install them using APT.
Ubuntu

Related

An item with the same key has already been added MAUI C#

When I try to run my program in release mode, it give this error:
Severity Code Description Project File Line Suppression State
Error XAGJS7004 System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Xamarin.Android.Tasks.TypeMapGenerator.GenerateRelease(Boolean skipJniAddNativeMethodRegistrationAttributeScan, List`1 javaTypes, String outputDirectory, ApplicationConfigTaskState appConfState)
at Xamarin.Android.Tasks.GenerateJavaStubs.WriteTypeMappings(List`1 types, TypeDefinitionCache cache)
at Xamarin.Android.Tasks.GenerateJavaStubs.Run(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.GenerateJavaStubs.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 MauiApp1 C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.440\tools\Xamarin.Android.Common.targets 1438
It is strange because in debug mode it works fine and I can't find any answer online.
Window snippet
There is fore sure some incompatibility between MAUI and .NET7, but you can set your project to use previous NET6 version following few steps:
Discover installed SDKs and keep note of the exact version 6
dotnet --info
SDKs list
Move to project folder and create a global.json file, it sets the NET SDK to be used. Be sure to set the installed SDK version:
dotnet new globaljson --sdk-version 6.0.301 --roll-forward disable
Restore workloads required by your project:
dotnet workload restore
Open project in Visual Studio, confirm to reload the project if requred.
Now your project will be built using NET6 SDK.
I solved it by uninstalling .net7, I found on Maui's github page people with the same problem and I think it will be fixed in the future.
It remains a shame Maui is not yet ready for .net7
Had the same problem, working on debug, this exception on release.
I solved it by: Clean Maui solution -> delete bin and obj -> Close Visual Studio -> Rebuild -> Working
Hope this helps if you didn't try

com.android.tools.r8.CompilationFailedException

When trying to build my Xamarin project in Visual Studio 2022 I am receiving this error:
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\120\lp\100\jl\bin\classes.jar : com/google/android/gms/measurement/internal/zzai.class
My build log shows this:
Error in obj\Debug\120\lp\100\jl\bin\classes.jar:com/google/android/gms/measurement/internal/zzai.class:
Type com.google.android.gms.measurement.internal.zzai is defined multiple times: obj\Debug\120\lp\100\jl\bin\classes.jar:com/google/android/gms/measurement/internal/zzai.class, obj\Debug\120\lp\101\jl\bin\classes.jar:com/google/android/gms/measurement/internal/zzai.class
I have used 7zip to extract the specified zzai.class file however I don't know what to do from here. Trying to edit the file in notepad++ just shows noninterpretable code.
I fixed the issue by uninstalling unnecessary NuGet packages for Xamarin.GooglePlayServices.Measurement, only keeping the dependent packages required for Xamarin.Firebase.Analytics:
Xamarin.GooglePlayServices.Measurement
Xamarin.GooglePlayServices.Measurement.Api
Xamarin.GooglePlayServices.Measurement.Sdk

MonoDevelop Error: Unknown MSBuild failure. Please try building the project again

Just installed MonoDevelop and I tried to compile a simple "Hello World".
Code I used:
using System;
public class HelloWorld
{
static public void Main ()
{
Console.WriteLine ("Hello Mono World");
}
}
The error that I get is :
EmptyCSharpFile.csproj(1,1): Error: Unknown MSBuild failure. Please try building the project again (EmptyCSharpFile)
My system info:
Ubuntu 16.04 LTS , updated
The MonoDevelop and mono are freshly installed.
Mono JIT compiler version 5.0.1.1
MonoDevelop Version 5.10
I can use mcs and run it but can't use monodevelop to run it.
I did read these similar topics but no response yet:
MonoDevelop Failure "Unknown MSBuild Failure" on Linux ;
C# compile Unknown MSBuild error MonoDevelop Linux ; https://askubuntu.com/questions/73630/could-not-obtain-c-compiler-error-when-using-monodevelop
I too had the same problem when I first installed it , I assume you went straight to file -> new-> file-> general -> emptyc# file.
Instead of that, go to file->new-> solution from there choose Console C# project or simply press ctrl + shift + N choose next ,and give project name, by default the new project has a simple hello world program run it, this time it will work.(it worked for me)

Using Mitov.Plotlab in my C# project, "Entry not found" error messagebox raise in design

error window one
ps: The translation for image: "无法找到入口" -> "Entry not found", "无法定位程序输入点 于动态链接库" -> "Can not locate the program entry point in the dynamic link library."
In other compute is ok, this quiestion only in my notebook.
OS: win10 enterprise
VS Version: 2015
Plotlab Version: 7.8.2
Error Window Number: many of them
I tried many way:
List item
update system
Repair vs2015
Install all version with C++
Running with administrator
Install on C:\
Reinstall Plotlab
Answer from Boian Mitov.
You probably have switched from an older installation, and there is some left over stuff.
Can you please try this version first:
http://www.mitov.com/PlotLab_NET_7.8.2.95.zip
There are some improvements in it.

Error MCG0004:InternalAssert Assert Failed when building UWP app in release mode

I have an UWP app written in C# which builds (VS 14.0.25425.01 Update 3 on Windows 10.0.14393, target version of the project is build 14393) and runs in Debug mode, but fails to build in Release mode with the following error:
Microsoft.NetNative.targets(640,5): error : MCG0004:InternalAssert Assert Failed: field not found during [UNKNOWN]
There are no further details, except for two warnings before, which I am not sure whether they are related to the problem:
Resources.System.Linq.Expressions.rd.xml(35): warning : ILTransform : warning ILT0027: Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found.
Resources.System.Linq.Expressions.rd.xml(91): warning : ILTransform : warning ILT0027: Method 'ParameterIsAssignable' within 'System.Linq.Expressions.Expression' could not be found.
Any suggestions what the issue could be related to?
This error will occur if you're using the Beta package for .NET UWP tools with VS 2015. The Beta package is only supported on 2017 as there are changes to how deployment/debugging work that we rely on. You should be able to avoid the issue by downgrading from "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.0-beta2" to "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
edit: 5.3.0 has been published and works with VS2017 RC3+. More information here: https://blogs.msdn.microsoft.com/dotnet/2017/01/30/announcing-net-core-net-native-and-nuget-updates-in-vs-2017-rc/
Disclaimer: I work on the .NET Native compiler+runtime team.

Categories

Resources