Unable to build application with "compile with .NET Native tool chain" option - c#

First of all the biggest issue is that it seems I must use "compile with .NET Native tool chain" option. With out it I'm unable to pass verification with the following errors
◦API OpenSemaphore in api-ms-win-core-synch-l1-1-0.dll is not supported for this application type. System.Threading.dll calls this API.
◦API CreateSemaphore in api-ms-win-core-kernel32-legacy-l1-1-0.dll is not supported for this application type. System.Threading.dll calls this API.
◦API ExecuteAssembly in uwphost.dll is not supported for this application type. FileDownloader.exe calls this API.
◦API DllGetActivationFactory in uwphost.dll is not supported for this application type. FileDownloader.exe has an export that forwards to this API.
   I found on other forums that this errors usually happen because the application is build without "compile with .NET Native tool chain" option.
   Unfortunately, I cannot build with that option either because of the following error
C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\IlcInternals.targets(936,5): error : Internal compiler error: Unable to cast object of type 'Microsoft.Cci.Immutable.Vector' to type 'Microsoft.Cci.IGenericTypeInstance'.
   Does anybody know how to fix it?
Thank you
Alex

Related

Unable to load libgdiplus in Signal R web application with web sockets (Mac OS)

I downloaded this repository from GitHub and try to run it on my MacOS laptop. It uses Signal R and web sockets.
It builds, it starts, it works
But when I try to open web socket I get an error:
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: 'liblibgdiplus' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache), 'liblibgdiplus' (no such file), '/usr/local/lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache)
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
I did brew install mono-libgdiplus but it didn't help.
I'm new to C# and Microsoft frameworks so what else can I do? (MacOS Ventura, Apple M1)
Solved: System.Drawing is not supported on my MacOS, so the peaces of code where this library is using should not be executed.
While the project you played with was very well designed for cross platform, it was unfortunately developed before .NET 6 introduced an important breaking change, that System.Drawing related API is only supported on Windows.
Like you found out, commenting out the lines related to System.Drawing works. But if you want similar functionalities, you will have to rewrite that part with another drawing library. There are many such options out there if search engines are used.

Error : Unable to load DLL 'libgmp-10.dll' when testing azure function c# .net 5.0

I published my c# .NET 5.0 code to azure functions (windows) and im getting this weird error message:
2021-06-21T01:56:53.465 [Error] Executed 'Function1' (Failed, Id=fdefdbba-49a7-44ad-8082-841d2941d90b, Duration=169ms)Unable to load DLL 'libgmp-10.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I tried to see the \wwwroot files on the azure functions console but then i get this error:
3 [main] ls (8392) C:\Program Files\Git\usr\bin\ls.exe: *** fatal error - Couldn't set directory to \\?\PIPE\ temporarily.
Any hints?
It seems that the deployment is not done correctly.
Libgmp-10.dll a DLL (Dynamic Link Library) file which is referred to
essential system files of the Windows OS. It usually contains a set of
procedures and driver functions, which may be applied by Windows.
Please delete the Azure Function and, re-create and deploy a fresh code using Develop and publish .NET 5 functions using Azure Functions OR if you are using ADO, Setting up a CI/CD pipeline for Azure Functions.
Let me know if you have any follow up questions.

Can i build C# projects on Ubuntu with Jenkins?

We have Jenkins running on an Ubuntu OS 18.04.01 LTS and an older project written in C# / .NET 4.5
The application was always build manually in the past and I would like to use Jenkins to introduce CI so nobody needs to build the project manually anymore. The application does not have to run on Linux or anything like that, we just need the buildfiles (executables and DLL files). Is it possible to build this C# solution with Jenkins on Ubuntu?
I know about MONO and XBUILD but actually I can't manage to build the project under ubuntu because of different issues which do not happen under Windows, e.g. see here:
UserControls/ExpandablePanel.cs(33,35): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
UserControls/ExpandablePanel.cs(33,66): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
UserControls/ExpandablePanel.cs(35,41): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
UserControls/ExpandablePanel.cs(37,40): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
UserControls/ExpandablePanel.cs(133,22): error CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 6.0 language specification
UserControls/PagedDataGridView.cs(441,68): error CS1043: Invalid accessor body `=>', expecting `;' or `{'
1 Warning(s)
6 Error(s)
Is it even possible or do I definitely need to run Jenkins on a Windows machine?
It is possible. You can build C# project on Linux/Ubuntu. Try building using mono. When you will install mono package, one of the binaries that you will get will be xbuild. To build just invoke the following command:
xbuild <path to csproj/solution file>
Try building this manually first and then integrate with jenkins.

UWP Create App Package fails for release mode

I am trying to create app package for a UWP app (side loading) in release mode it fails with below error. It works fine for debug mode
Severity Code Description Project File Line Suppression State
Error ILT0021: Could not resolve type
'System.Security.SecurityZone' MyApp.ModuleName
Project Properties
When I enable Compile with .NET Native tool chain, I get following error
Severity Code Description Project File Line Suppression State
Error ILT0005:
'C:\Users\username.nuget\packages\runtime.win10-x86.microsoft.net.native.compiler\2.1.8\tools\x86\ilc\ilc.exe
--gatekeeper #"C:\Projects......\obj\x86\Release\ilc\intermediate\gkargs.rsp"'
returned exit code 1 MyApp.Module
When I try to do build on Azure DevOps I get this error
(BuildNativePackage target) -> 2019-02-06T15:14:28.4996296Z
C:\Program Files (x86)\Microsoft
SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.1\tools\Microsoft.NetNative.targets(792,5):
error : ILT0021: Could not resolve type 'System.Security.SecurityZone'
[D:\a\1\s\ProjectFolder\MyApp.ModuleName.csproj]
Update 02/14/2019
Problem was with bunch of Powershell packages I installed from nuget, I removed it all now I am able to create the package. But the package fails to pass App Certification Kit test with the following errors
Windows security features test
FAILED Binary analyzer Error Found: The binary analyzer test detected
the following errors: File C:\Program
Files\windowsapps\myapp.module.subver_1.0.21.0_x64__7p23rrj50tgdp\clrcompression.dll
has failed the AppContainerCheck check.
Supported API test
FAILED Supported APIs Error Found: The supported APIs test detected
the following errors: API sysctl in libc.dll is not supported for this
application type. Microsoft.DotNet.PlatformAbstractions.dll calls this
API. API RtlGetVersion in ntdll.dll is not supported for this
application type. Microsoft.DotNet.PlatformAbstractions.dll calls this
API. API LoadLibraryExW in kernel32.dll is not supported for this
application type. clrcompression.dll calls this API. API
RtlCaptureContext in kernel32.dll is not supported for this
application type. clrcompression.dll calls this API. API
RtlVirtualUnwind in kernel32.dll is not supported for this application
type. clrcompression.dll calls this API. API UnhandledExceptionFilter
in kernel32.dll is not supported for this application type.
clrcompression.dll calls this API. API ExecuteAssembly in uwphost.dll
is not supported for this application type.
MyApp.Subver.exe calls this API. API
DllGetActivationFactory in uwphost.dll is not supported for this
application type. Myapp.subver.exe has an export that
forwards to this API.

Unhandled Exception: System.InvalidProgramException: Common Language Runtime det ected an invalid program

I bought a new computer recently and uploaded this project to a FTP server and then downloaded it to my new computer but now it is causing this error:
Unhandled Exception: System.InvalidProgramException: Common Language Runtime det
ected an invalid program.
at Nancy.Conventions.NancyConventions.<Validate>b__1(Tuple'2 result)
at System.Linq.Enumerable.WhereEnumerableIterator'1.MoveNext()
at Nancy.Conventions.NancyConventions.Validate()
at Nancy.Bootstrapper.NancyBootstrapperBase'1.Initialise()
at Nancy.Hosting.Self.NancyHost..ctor(INancyBootstrapper bootstrapper, HostCo
nfiguration configuration, Uri[] baseUris)
at Nancy.Hosting.Self.NancyHost..ctor(Uri baseUri, INancyBootstrapper bootstr
apper, HostConfiguration configuration)
at PokerServer.Program.startServer() in f:\Projects\Visual Studio\PokerServer
\PokerServer\Program.cs:line 93
at PokerServer.Program.Main() in f:\Projects\Visual Studio\PokerServer\PokerS
erver\Program.cs:line 23
It worked well on the old computer.
I have updated .NET (and all other updates under Windows Update as mentioned in another thread).
I have tried deactive and active "Code optimization" without any problems.
The directory is not the same as before, not sure if that can cause this problem?
I verify my code with peverify and if I understand it correctly everything looks good:
F:\Projects\Visual Studio\PokerServer\PokerServer\bin\Debug>peverify PokerServer
.exe /md /il
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in PokerServer.exe Verified.
Any help is highly appreciated!
Are you actually compiling the project on the new computer or just running the application?
If you're just running it, did you verify that the application assembly or assemblies are actually identical on both computers? I suggest, you first rule out the option, that something happened during the data transfer.
If you're compiling it, what are you compiling it with? VIsual Studio? Which version?
In any case, the error is not related to the file directory, the application is in. According to MSDN, the exception should only be thrown when the compiled application is invalid (i.e. in case of a bug in the compiler). You can find more info in this knowledge base article. Try running the PEVerify tool and rebuilding the application in debug configurtion as the article suggests.
I removed the old Nancy dependency and installed it again from Nuget and now it works.

Categories

Resources