Running Mono 3.2.0 with .NET MVC 4 - asp.net

I am trying to get Mono 3.0 setup to run MVC4 sites under .NET 4 and .NET 4.5. I've been working through various errors, what can I do to get it up and running?
Server Configuration
CentOS 5
Apache 2.2.3
3.2.0 (tarball Sun Jul 28 00:57:40 UTC 2013); ASP.NET Version: 4.0.30319.17020
2013)
Latest XSP from git, as of the time of this post
Apache/Mono Config
MonoServerPath "/usr/local/bin/mod-mono-server4"
/usr/local/bin/mod-mono-server4 contents:
#!/bin/sh
exec /usr/local/bin/mono $MONO_OPTIONS "/usr/local/lib/mono/4.5/mod-mono-server4.exe" "$#"
Update
The crux of the problem is that Mono doesn't ship with MVC4 which the site requires. It still has the MVC3 dlls, yet it has the Razor 2 dlls but not the Razor 1 dlls which MVC3 wants to sue.

Everything you need is now available within the Mono framework or on NuGet. I've created downloadable template for MVC4 for .Net 4.0 and .Net 4.5 and some notes on resolving the issues:
http://www.cafe-encounter.net/p1510/asp-net-mvc4-net-framework-version-4-5-c-razor-template-for-mono-on-mac-and-linux
The steps from the blog post are:
git clone
github.com/chrisfcarroll/AspNetTemplatesForMono/Mvc4CSharpRazorFx45Intranet
NB This github repo includes all the required dlls in case you don’t
have NuGet working, so it’s an oversized download.
Open the solution in Xamarin Studio. It almost works out-of-the-box.
The one thing you have to do is choose one of these 2 steps to make
it work:
Either delete Microsoft.Web.Infrastructure.dll from the bin\ directory and from the project
Or, from the command line:
sudo mkdir /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
sudo chmod g+rwx /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
(replacing 3.2.5 with your mono version, which you get at the command line with mono --version);
The Microsoft.Web.Infrastructure.dll is required on .Net on Windows, so deleting it is not the simpler approach if you want cross-platform deployability

Success
If you want to run MVC4 on Mono, you need to use some Microsoft dlls which are not provided by Mono at this time.
A word of caution - Taking a cursory look at the Mono source, there appears to be methods and classes in the MC4 source that do not exist in the 3.2.0 build. There may be features that are broken. The site I am running is for all intents and purposes an MVC3 site built against the latest dlls.
Microsoft DLLs to copy
System.Web.Abstractions - 4.0
System.Web.Helpers - 2.0
System.Web.Mvc - 4.0
Once you copy over the dlls, if you're still having problems you may have to do some detective work if the above fix doesn't work. If you get an error message saying that Mono can't find the DLL, it's usually one of three reasons:
Troubleshooting
Is doesn't have the dll - You can try using the Microsoft version of the DLL
It's looking for an older version of the DLL when the correct one is installed in the GAC or in your project folder - An assembly in your project is likely referencing that version somewhere. You can use a binding re-direct to force the specific version you have be used instead
It stil can't find the dll - Add the assembly in the compilation/assemblies section of your web.config
You're getting a 'can't find view searched...' message - if any of the views in that particular views folder have compile errors, then you'll receive this message.

Related

Upgrading runtime and sdk and packages to .NET 6

I was following this tutorial on building an application with ASP.NET Core API and Angular where I used a laptop that had .NET 5 installed.
I got a new laptop and after I installed all the latest tools, I am now on .NET 6 and when I open my app to carry on where I left off, I get the following error when I run dotnet watch run in the VS Code terminal in the backend folder:
The framework 'Microsoft.AspNetCore.App', version '5.0.0' (x64) was not found.
- The following frameworks were found:
6.0.5 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=x64&rid=win10-x64
Here are 2 screenshots showing what I have installed in this app from the time I was using it on my old laptop (now opening it and trying to run it on my new laptop)
Is there anyway I can cleanly update everything I need in one go, instead of installing .NET 5 or AspNetCore.App version 5.0.0 etc?
Just correct the TargetFramework element's text content to net6.0.
Also update the NuGet packages.
Don't mind what's inside the bin and obj folders, whereas exist. Even better, make sure to Clean or Rebuild your project.

Run dotnet-sos, dotnet-dump, dotnet-gcdump for a self-contained .NET Core application on Linux

I have an Ubuntu 18.04 x64 Linux server running a bunch of .NET Core applications. All of them are published as self-contained applications and .NET Core versions vary between 2.1, 3.1 and 5.0. I don't have .NET Core runtime (let alone SDK) installed on the machine and do not want to install it.
I want to run tools such as dotnet-sos, dotnet-dump and dotnet-gcdump for a .NET Core 3.1 self-contained application. The linked pages provide direct download links for them, e.g. https://aka.ms/dotnet-sos/linux-x64. However, when I run the downloaded dotnet-sos tool it fails with
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/var/tmp/.net/MY_USERNAME/dotnet-sos/mrdxw5vu.czm/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.18.04-x64
This happens even if the current working directory is my .NET application directory, which contains
libhostfxr.so. The error implies that running the tool for a self-contained application should be possible, but the file indeed does not exist in /var/tmp/.net/MY_USERNAME/dotnet-sos/mrdxw5vu.czm/. If I manually copy that file to the above directory it then fails with
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.18.04-x64
How do I run such tools without installing the .NET runtime machine-wide? I can easily download the binaries from https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-3.1.14-linux-x64-binaries but where do I put them for the tool to find them?
Turns out the .NET SDK can be extracted to any directory and then used to install and run dotnet-dump and dotnet-gcdump like this:
curl -fsSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash -s -- --no-path --install-dir ~/dotnet-sdk --channel 5.0
~/dotnet-sdk/dotnet tool install --tool-path ~/dotnet-sdk/tools dotnet-dump
DOTNET_ROOT=~/dotnet-sdk ~/dotnet-sdk/tools/dotnet-dump collect -p PID_TO_DUMP
(I did not manage to get SOS working in LLDB, however. "Installing" it works just as above, but it fails to load in LLDB.)

How do I install dotnet framework help files for VS Code

I'm using VS Code to write a dotnet core application. Everything works fine but when intellisense kicks in (or I hover over a system API) I don't get any documentation for those methods. I assume that there is an extension for this? Event the node.js system for VS Code includes documentation.
I must be searching for the wrong terms because I can't even find one discussion about this topic.
UPDATE: July 23, 2020 Thanks omajid. I was actually using some apis from System.IO
While I have the xml docs for many dlls, not that assembly:
System.IO.MemoryMappedFiles.xml
System.IO.Pipes.dll
System.IO.Pipes.xml
System.IO.UnmanagedMemoryStream.dll
System.IO.dll
System.Linq.Expressions.dll
System.Linq.Expressions.xml
System.Linq.Parallel.dll
System.Linq.Parallel.xml
System.Linq.Queryable.dll
System.Linq.Queryable.xml
I guess I'll try to reinstall dotnet.
Also missing the core dll documentation files:
mscorlib.dll
netstandard.dll
After an install I still have the problem. I can find System.IO.xml in other directories for other languages like here:
.//dotnet/sdk/NuGetFallbackFolder/system.io/4.1.0/ref/netstandard1.5/fr/System.IO.xml
.//dotnet/sdk/NuGetFallbackFolder/system.io/4.1.0/ref/netstandard1.5/System.IO.xml
.//dotnet/sdk/NuGetFallbackFolder/system.io/4.1.0/ref/netstandard1.5/es/System.IO.xml
UPDATE July 26: I found part of the issue. One of my libs was netstandard2.0, another was netstandard 2.1. The newer project had help. See the issue https://github.com/dotnet/runtime/issues/39927
UPDATE August 19, 2020: The issue was marked as a duplicate of this issue: https://github.com/dotnet/standard/issues/1527
The documentation is looked up the .xml files that are included in the .NET Core installation.
For each namespace, there's a .xml file as well as a .dll file. For exmaple, in my .NET Core installation, these are the files for System.IO.Pipes:
$ find /usr/lib64/dotnet -iname 'System.IO.Pipes*' | grep 'NETCore.App' | grep -v Access
/usr/lib64/dotnet/packs/Microsoft.NETCore.App.Ref/3.1.0/ref/netcoreapp3.1/System.IO.Pipes.dll
/usr/lib64/dotnet/packs/Microsoft.NETCore.App.Ref/3.1.0/ref/netcoreapp3.1/System.IO.Pipes.xml
/usr/lib64/dotnet/shared/Microsoft.NETCore.App/3.1.5/System.IO.Pipes.ni.{742a0de4-c892-41d7-a15d-0ecd8de52518}.map
/usr/lib64/dotnet/shared/Microsoft.NETCore.App/3.1.5/System.IO.Pipes.dll
/usr/lib64/dotnet/shared/Microsoft.NETCore.App/3.1.5/System.IO.Pipes.pdb
The targetting pack directory (packs/Microsoft.NETCore.App.Ref) contains both the reference assembly (System.IO.Pipes.dll) and also the XML documentation (System.IO.Pipes.xml). It sounds like your distribution of .NET Core is broken if it's missing the XML documentation files.
How did you install .NET Core? Can you re-install it? If the problem still persists, can you share more information about how we can reproduce your environment?
We hit this bug in .NET Core on Fedora Linux a little while ago: https://bugzilla.redhat.com/show_bug.cgi?id=1831310

Issue to install core3.1 VSBuildTools offline installer 2017 using workload

When we trying to install the offline installer which is generated using below workload getting exited with errorlevel 1 . Any advise please?
.\vs_buildtools__140882496.1541481122.exe --layout .
--add Microsoft.VisualStudio.Workload.MSBuildTools
Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools
Microsoft.VisualStudio.Workload.WebBuildTools
Microsoft.VisualStudio.Workload.NetCoreBuildTools
Microsoft.Net.Component.4.5.2.TargetingPack
--lang en-US
Error
Something went wrong with the install.
If the issue has already been reported on the Developer Community, you can find solutions or workarounds there. If the issue has not been reported, we encourage you to create a new issue so that other developers will be able to find solutions or workarounds. You can create a new issue from within the Visual Studio Installer in the upper-right hand corner using the "Provide feedback" button.
================================================================================
Package 'Microsoft.Net.4.7.2.FullRedist,version=4.7.3062.3' failed to install.
Search URL
https://aka.ms/VSSetupErrorReports?q=PackageId=Microsoft.Net.4.7.2.FullRedist;PackageAction=Install;ReturnCode=16389
Details
Command executed: "C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Net.4.7.2.FullRedist,version=4.7.3062.3\dotNetFxLatest-x86-x64-AllOS-ENU.exe" /q /norestart /KeepAUPaused /ChainingPackage Visual_Studio_15_Setup /CEIPconsent /log "C:\Users\Administrator\AppData\Local\Temp\dd_setup_20200103140616_004_Microsoft.Net.4.7.2.FullRedist.log"
Return code: 16389
Return code details: Unknown error (0x00004005)
Log
C:\Users\Administrator\AppData\Local\Temp\dd_setup_20200103140616_004_Microsoft.Net.4.7.2.FullRedist.log
Impacted workloads
.NET desktop build tools (Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools,version=16.4.29511.114)
MSBuild Tools (Microsoft.VisualStudio.Workload.MSBuildTools,version=16.0.28516.191)
Web development build tools (Microsoft.VisualStudio.Workload.WebBuildTools,version=16.4.29409.204)
Impacted components
.NET Framework 4.7.2 development tools (Microsoft.Net.ComponentGroup.DevelopmentPrerequisites,version=16.3.29207.166)
.NET Framework 4.7.2 targeting pack (Microsoft.Net.Component.4.7.2.TargetingPack,version=16.0.28517.75)
C# and Visual Basic Roslyn compilers (Microsoft.VisualStudio.Component.Roslyn.Compiler,version=16.0.28714.129)
MSBuild (Microsoft.Component.MSBuild,version=16.4.29429.68)

sqllite3.dll issues with UWP app development for Mobile

I am trying to learn how to develop apps for UWP for both Desktop and Mobile. I have been currently working on getting the Entity Framework working in my app to store application state and followed the following link:
https://learn.microsoft.com/en-us/ef/core/get-started/uwp/getting-started
It worked well for Desktop, the issue however is that when I try to run it on the Windows Mobile emulator I get the following error in debug mode when the code reaches the db.Database.Migrate() step:
Unable to load DLL 'sqlite3': The specified module could not be found
In the link I pasted above, someone else had the same issue and in the comments they recommended to try the following:
Step 1: Install SQLite VSIX pacakge for Universal Windows Platform development using Visual Studio 2015
https://www.sqlite.org/2016/sqlite-uwp-3130000.vsix
Step 2: Install NuGet package SQLite.NET-PCL
Install-Package SQLite.NET-PCL
Step 3: Add references
Add Reference -> Universal Windows ->Extensions -> Make sure the following packages have been checked: "SQLite for Universal Windows Platform" "Visual C++ 2015 Runtime for Universal Windows Platform Apps"
After that, if you get the error "Payload contains two or more files with the same destination path 'sqlite3.dll', do the following:
copy sqlite3.dll from
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll
past to (override it)
C:\Users\%USERNAME%\.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll
The problem after doing those steps is that I am now seeing the issue when doing a build for "Payload contains two or more files" however not in the SQLitePCL.raw_basic directory (I don't even seem that have that). Instead my error is the following:
Payload contains two or more files with the same destination path 'sqlite3.dll'. Source files:
C:\Users\admin\.nuget\packages\SQLite\3.13.0\runtimes\win7-x86\native\sqlite3.dll
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UWP.2015\3.13.0\Redist\Debug\x86\sqlite3.dll
I have been searching everywhere and am truly stumped as to how to get my UWP program working on Mobile. Thanks a lot for your help!
It seems like you got the solution for resolving the exception The specified module could not be found from #Leandro_Medeiros_Machado 's comment on this document. If you got the Payload contains two or more files with the same destination path 'sqlite3.dll' exception after you done the above three steps you may be also found the next solution from the comment.
After that, if you get the error "Payload contains two or more files with the same destination path 'sqlite3.dll', do the following:copy sqlite3.dll from
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll
past to (override it)
C:\Users\%USERNAME%\.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll
For you, you may need to copy from
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UWP.2015\3.13.0\Redist\Debug\x86\sqlite3.dll to(override) C:\Users\admin\.nuget\packages\SQLite\3.13.0\runtimes\win7-x86\native\sqlite3.dll.
But actually, for using EF core you don't need the above steps and I recommend you check your environment instead of using the above workaround. I created a simple EF project by following the document and without install the VSIX I can run successfully on the emulator (build 10586). My VS build is 2015 update 3, my OS version is build 14393 and the EF core version is Microsoft.EntityFrameworkCore.Sqlite 1.1.0. So please firstly check if your environment met the following requirements:
Windows 10
Visual Studio 2015 Update 3
The latest version of Windows 10 Developer Tools
And if your EF core and EF core tools versions are right.

Resources