Mono MSBuild error after installing reference assemblies Ubuntu 18.04 - msbuild

I would like to build a .net framework 4.7.2 project in Mono on Ubuntu 18.04
I installed mono-devel according to this guide:
https://www.mono-project.com/download/stable/
After installing and trying to run msbuild on one of my projects, I get this error:
/usr/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(1195,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
I found a reference assemblies package which I installed:
mono-reference-assemblies-4.0
After installing the package and running the build again, I am getting the following error:
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x000bb] in <0fd2831d9cb34830af9027441f77a417>:0
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x003f2] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.CommandLine.MSBuildApp.Main () [0x00028] in <0fd2831d9cb34830af9027441f77a417>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance () [0x00017] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.Utilities.Traits.get_Instance () [0x00000] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x003f2] in <0fd2831d9cb34830af9027441f77a417>:0
at Microsoft.Build.CommandLine.MSBuildApp.Main () [0x00028] in <0fd2831d9cb34830af9027441f77a417>:0
This error occurs wherever I run msbuild from. It seems like it should be possible to build my project.
Any help would be greatly appreciated.

mono-reference-assemblies-4.0 package doesn't come from the stable channel of the new apt source that you added to install your new version of Mono, so you're mixing versions of Mono at runtime, which is causing those weird exceptions.
The solution is to uninstall this package and switch to unstable channel (because .NET 4.7.2 is too new for the stable one).

Related

"Could not load file or assembly or one of its dependencies" in Mono but not in native .NET

The same executable that uses some proprietary DLLs, after being compiled with Mono, works natively on Windows, but doesn't work using Mono on Windows or Linux.
hello_onbase.cs:
using Hyland.Unity;
using Hyland.Types;
using System;
public class HelloOnBase
{
public static void Main(string[] args)
{
var auth = Application.CreateOnBaseAuthenticationProperties("app_server_url", "user", "password", "data_source");
var app = Application.Connect(auth);
Console.WriteLine ("OnBase connection successful!");
}
}
Proprietary DLLs Hyland.Unity.dll and Hyland.Types.dll are in the same directory as the file hello_onbase.cs. Unfortunately I can't share those files since they're the IP of our vendor, I'm very sorry...
I opened Mono x64 Command Prompt in Windows and compiled the file successfully with Mono:
C:\Users\apanasenco\git\docaccess\services\doc\onbase>csc -r:Hyland.Types.dll -r:Hyland.Unity.dll hello_onbase.cs
Microsoft (R) Visual C# Compiler version 3.6.0-4.20224.5 (ec77c100)
Copyright (C) Microsoft Corporation. All rights reserved.
The executable Mono compiled executes just fine natively in Windows:
C:\Users\apanasenco\git\docaccess\services\doc\onbase>hello_onbase.exe
OnBase connection successful!
However, running the executable with mono causes the following error:
C:\Users\apanasenco\git\docaccess\services\doc\onbase>mono hello_onbase.exe
Unhandled Exception:
System.TypeLoadException: Could not set up parent class, due to: Could not set up parent class, due to: Could not load type of field 'Hyland.Types.EncryptedServiceObject:_scp' (2) due to: Could not load file or assembly 'Hyland.Security.Legacy, Version=0.2.2.0, Culture=neutral, PublicKeyToken=e169a6a902bdd7a6' or one of its dependencies. assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:EncryptedServiceObject member:(null) assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:ParameterizedObject member:(null)
at Hyland.Unity.OnBaseAuthenticationProperties.ConnectNormalMode (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00000] in <80532c8c2f134d0daba2ee8243cb5721>:0
at Hyland.Unity.OnBaseAuthenticationProperties.ConnectAndGetIntegrationApplicationOptions (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
at Hyland.Unity.Application.Connect (Hyland.Unity.AuthenticationProperties connectProperties) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
at HelloOnBase.Main (System.String[] args) [0x0001b] in <73b1617068fa44e792f55cccc5974b17>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not set up parent class, due to: Could not set up parent class, due to: Could not load type of field 'Hyland.Types.EncryptedServiceObject:_scp' (2) due to: Could not load file or assembly 'Hyland.Security.Legacy, Version=0.2.2.0, Culture=neutral, PublicKeyToken=e169a6a902bdd7a6' or one of its dependencies. assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:EncryptedServiceObject member:(null) assembly:C:\Users\apanasenco\git\docaccess\services\doc\onbase\Hyland.Types.dll type:ParameterizedObject member:(null)
at Hyland.Unity.OnBaseAuthenticationProperties.ConnectNormalMode (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00000] in <80532c8c2f134d0daba2ee8243cb5721>:0
at Hyland.Unity.OnBaseAuthenticationProperties.ConnectAndGetIntegrationApplicationOptions (Hyland.Unity.Services.IConnectServiceAccess connectServiceAccess) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
at Hyland.Unity.Application.Connect (Hyland.Unity.AuthenticationProperties connectProperties) [0x00020] in <80532c8c2f134d0daba2ee8243cb5721>:0
at HelloOnBase.Main (System.String[] args) [0x0001b] in <73b1617068fa44e792f55cccc5974b17>:0
Mono version on Windows and Linux: 6.12.0
The older versions of these two files used to work on Mono before... I'm wondering if there's some Mono setting I can tweak to relax some assembly checks to match native .NET behavior?
Turns out the vendor does provide a file Hyland.Security.Legacy.dll that was alluded to in the error message. Including that file resolved the issue.

Getting an Unexpected Error in dotnet core Project

In my solution Explorer(Visual Studio) there are 5 projects
DigiIdentity(webapi)
Core(class library)
Data(class library)
Services(class library)
DigiPigmyApi(webapi)
DigiSyncApi(webapi)
I am getting following error while running the project(solution)
Error CS1705 Assembly 'Microsoft.AspNetCore.Hosting' with identity 'Microsoft.AspNetCore.Hosting, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' uses 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Hosting.Abstractions' with identity 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Actually I am not finding the Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.1.0 package anywhere, can any one tell me the exact course of the error.

Facing "Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, ' or one of its dependencies." [duplicate]

This question already has answers here:
Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35'
(8 answers)
Closed 5 years ago.
I am trying to deploy a MVC Web API solution on the server. The server has Windows 2012 R2 operating system. This is MVC 4 based Web API solution.
The server has .Net 4.0 framework installed. Except this server machine the solution has been deployed and working fine as expected. NOTE: those other machines has Visual Studio installed.
My issue here is - no matter whichever method I am applying, either solution itself or publish the solution, it is not working and giving below error.
Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
The stack trace says:
[FileNotFoundException: Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
OSCARService.WebApiApplication.Application_Start() +0
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +544
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +186
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716
I tried finding this file (System.Web.Http.WebHost) in the framework directory but am unable to find this specific file.
I wonder Is this file necessarily required to be available physically?
I also tried setting System.Web.Http DLL to "CopyLocal='True'" but didn't work.
I already tried looking for similar situation/questions-answers here, but couldn't really get any direction.
I'd appreciate if anyone could provide direction here to my issue.
I fixed this by reinstalling the NuGet package, which corrects broken dependencies. From the package manager, try running this command
Update-Package Microsoft.AspNet.WebApi -reinstall
Check the bin folder of your deployed project. It should contain System.Web.Http.WebHost.dll. If this dll is in this folder, check the version. If it isn't 4.0.0.0, then you should deploy version 4.0.0.0. If you are using nuget packages, check your packages.config else check your web.config if you have the right version installed.
Hope this helps

SolrNET Ninject Integration Error- Could not load file or assembly 'HttpWebAdapters'

I had successfully implemented Solrnet using Ninject Integration. However it suddenly started failing yesterday giving the following error.
Could not load file or assembly 'HttpWebAdapters, Version=0.4.0.2002, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Here is the stack trace:
[FileNotFoundException: Could not load file or assembly 'HttpWebAdapters, Version=0.4.0.2002, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
SolrNet.Impl.SolrConnection..ctor(String serverURL) +0
Ninject.Integration.SolrNet.SolrNetModule.Load() in c:\Users\kanja-1\Documents\Visual Studio 2012\Projects\Ninject.Integration.SolrNet\Ninject.Integration.SolrNet\SolrNetModule.cs:205
Ninject.Modules.NinjectModule.OnLoad(IKernel kernel) in c:\Projects\Ninject\ninject\src\Ninject\Modules\NinjectModule.cs:85
Ninject.KernelBase.Load(IEnumerable1 m) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:217
Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:100
Ninject.KernelBase..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:57
Ninject.StandardKernel..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\StandardKernel.cs:46
MealsToGo.App_Start.NinjectWebCommon.CreateKernel() in c:\Users\kanja-1\Documents\Visual Studio 2012\Projects\MealsToGo\MealsToGo\App_Start\NinjectWebCommon.cs:53
Ninject.Web.Common.Bootstrapper.Initialize(Func1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:50
MealsToGo.App_Start.NinjectWebCommon.Start() in c:\Users\kanja-1\Documents\Visual Studio 2012\Projects\MealsToGo\MealsToGo\App_Start\NinjectWebCommon.cs:34
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
Does someone know what I need to do to fix this?
thanks

IronPython + Mono error - could not load signature

When trying to run IronPython from Mono, I get the following error:
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ mono ipy.exe 19:19:23
Could not load signature of IronPython.Runtime.List:get_Item due to:
Failed to load language 'IronPython 2.7': Could not load type 'IronPython.Runtime.List' from assembly 'IronPython, Version=2.7.0.40, Culture=neutral, PublicKeyToken=7f709c5b713576e1'.
Fiddling around here on SO I found MONO_LOG_LEVEL=debug, and got this relevant information
Mono: Assembly Loader probing location: '/usr/lib/System.Numerics.exe'.
Mono: The following assembly referenced from /home/wayne/Downloads/IronPython-2.7.3/IronPython.dll could not be loaded:
Assembly: System.Numerics (assemblyref_index=5)
Version: 4.0.0.0
Public Key: b77a5c561934e089
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/wayne/Downloads/IronPython-2.7.3/).
Mono: Failed to load assembly IronPython[0xddd180]
Mono: Could not load file or assembly 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
Could not load signature of IronPython.Runtime.List:get_Item due to:
Mono: gc took 520 usecs
Mono: Unloading domain ipy.exe[0x7faebd540cc0], assembly IronPython[0xddd180], ref_count=2
How can I get this working?
It turns out that the Numerics library wasn't installed:
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ apt-cache search mono numerics
libmono-system-numerics4.0-cil - Mono System.Numerics library (for CLI 4.0)
wayne#arglefraster ~/Downloads/IronPython-2.7.3 ⚘ sudo apt-get install libmono-system-numerics4.0-cil
And off it went!