asp.net-core MVC rc2 using net451 on linux - asp.net-core

I am trying to migrate my website from dotnet core rc1 to dotnet core rc2, but I faced an error, then I tried to run a small test and it also didn't work for me.
This is my teste: https://github.com/ricardoalcantara/WebApplicationBasic
My environment is:
Debian 8.4
Mono 4.2.3
dotnet 1.0.0-preview1-002702
I need to run it on top of the "framework": "net451" because my main project needs few libs which still just run on that platform, so I am running with this command line:
dotnet run --framework .NETFramework,Version=v4.5.1
it actually runs, but when I try to access localhost:5000 it throws a long stack error mainly with that message:
z2cw6v06.4ja(43,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(43,50): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
z2cw6v06.4ja(43,10): error CS0518: Predefined type 'System.Void' is not defined or imported
z2cw6v06.4ja(45,10): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
z2cw6v06.4ja(45,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(45,50): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
z2cw6v06.4ja(45,10): error CS0518: Predefined type 'System.Void' is not defined or imported
z2cw6v06.4ja(47,10): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
z2cw6v06.4ja(47,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(47,50): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Can someone help me to solve that problem?
Obs.: It works on windows.

If you look closely, the error seems to be that MVC is failing to compile the view:
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:
pufduf6v.a1v(17,88): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
pufduf6v.a1v(17,88): error CS0518: Predefined type 'System.Boolean' is not defined or imported
pufduf6v.a1v(17,47): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
…
But running dotnet publish and then executing the result directly using mono works for me, e.g. (on Ubuntu):
mono bin/Debug/net451/ubuntu.14.04-x64/publish/WebApplicationBasic.exe
As was already explained to you on Github, this seems to be a known issue.

Related

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.

Loading a DLL in the GAC

currently I have a problem with getting a DLL into the Windows GAC. I tried to follow the steps of creating a DLL and loading it as described in this blog post:
http://blogs.technet.com/b/cloudpfe/archive/2014/02/01/how-to-create-a-custom-authentication-provider-for-active-directory-federation-services-3-0-part-2.aspx
At the point where I try calling the following command:
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7514a164b89fa979")
I get an error which tells me that System.EnterpriseServices could not be found:
Exception calling "Load" with "1" argument(s): "Could not load file or
assembly 'System.EnterpriseServices, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=7514a164b89fa979' or one of its dependencies. The
system cannot find the file specified."
The specified DLL (System.EnterpriseServices) does exist* on the machine.
So now my question is, why can't this method find the DLL and what do I have to do/change to get this command to work?
NOTE: I Tried this on a vanilla Windows Server 2012 R2 with just ADFS parts installed; And I've called the command from the Powershell.
*UPDATE: The System.EnterpriseServices DLL resides in
C:\Windows\Microsoft.NET\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a
and
C:\Windows\WinSxS\amd64_system.enterpriseservices_b03f5f7f11d50a3a_4.0.9600.1638‌​4_none_53a3f9b13fac0ba5\
So it should be available from the GAC.
I think your public Key token is incorrect, you found your own answer with your update :) .
It should be
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
Give this a try.

"Method 'Expire' in type 'ServiceStack.Redis.RedisNativeClient' from assembly

I get the following error when I try to load my webrole locally.
Method 'Expire' in type 'ServiceStack.Redis.RedisNativeClient' from assembly 'ServiceStack.Redis, Version=3.9.14.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
It was working yesterday... Any ideas?

ILMerge and MSBuild - merged EXE is giving runtime error

After adding ILMerge to my post build tasks and working out the commandline, I sucessfully get a merged program MyMerged.exe
But when I run it, I get an exception
Unhandled Exception: System.TypeLoadException:
Could not load type 'Microsoft.Build.Utilities.TaskItem' from assembly 'mymerged, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the method '.ctor' has no implementation (no RVA).
at MyProgram.Program.Main(String[] args)
Is this a bug in ILMerge not handling a situation where there is no constructor, or a bug in TaskItem for not having one.
thanks
Include Microsoft.Build.Utilities.dll on the ILMerge command line so that it will get merged in with your assembly and found.
If you have duplicate types defined and use the /allowDup command line switch, ILMerge will rename the duplicate types and this may also cause "Could not load type ..." errors and unexpected behavior during runtime, especially when reflection is being used.

Problem running latest version of nhibernate

I downloaded latest version of NHibernate “2.1.0.2002”.
It built fine, but when I run my unit tests, I keep getting error :-
System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
It looks like somewhere it looks of old version.
Here is link
https://stackoverflow.com/questions/839112/problem-while-migrating-nhibernate-to-higher-version
This is internal error I am getting:
=== Pre-bind state information ===
LOG: DisplayName = NHibernate, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///D:/Project Files/CIS3G/Webapp/_Test_DAL/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : CIS3G.DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Project Files\CIS3G\Webapp\_Test_DAL\bin\Debug\_Test_DAL.dll.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: NHibernate, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///D:/Project Files/CIS3G/Webapp/_Test_DAL/bin/Debug/NHibernate.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Please check if you set the Specific Version-Property on your NHibernate Reference to 'true'? It doesn't seem to be the case on this error but with new NHibernate you need to provide an external ByteCodeProvider like Linfu.dll as well. Please check this also.
I've run into this before.
In my case the problem was that I was using a UnitOfWork implementation for handling Nhibernate sessionFactories.
I've been using this lib for a while so I just copied the compiled dll to a new test project with the new version of NHibernate, so I got the version problem.