Using Microsoft Data Entity Framework with Microsoft MVC on Mono 2.4 - asp.net-mvc

I'm using Mono 2.4 on the Ubiquity web hosting service.
I created a simple MVC tutioal applciation, linked here, and verified that it worked using all Microsoft tools.
Next, the application was updated to point to a MySQL server database running on my Ubiquity host. The application works great on a Microsoft based machine.
Now, I am trying to deploy the application to the mono server on Ubiquity.
I set System.Web.MVC so it will CopyLocal=true.
I deployed the application to the mono server.
I get this error:
Description: Error parsing a resource required to service this request. Review your source file and modify it to fix this error.
Parser Error Message: Assembly System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 not found
Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433
I am guessing the problem could be...
A) The Entity framework is not supported in mono. I need to use something other than the Microsoft Data Entity Framework.
B) The public key token for the mono version of System.Data.Entity is not "b77a5c561934e089".
C) There is something else going on.
I tried setting CopyLocal=true for the System.Entity.Data dll. Thus, the Microsoft version of the DLL deployed to my mono server. I have doubts that this is legal. At any rate, that only produced the following error:
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
Question
Can somebody confirm that it is possible to use the Microsoft Entity Framework on Mono? I am probably going to migrate away from the Microsoft Entity Framework, per this comment in the Microsoft MVC tutorial linked above..
"The ASP.NET MVC framework is not tied to the Microsoft Entity Framework. You can create >your database model classes by taking advantage of a variety of Object Relational Mapping >(OR/M) tools including LINQ to SQL, Subsonic, and NHibernate."
However, for the sake of consistency, I would like to use the Microsoft Entity Framework on mono if that is possible.

I can confirm that EntityFramework, Microsoft Chart Controls, and Microsoft Sync Framework do NOT work on mono on Linux, despite different claims from Microsoft and/or MS-employees.
That is because Sync Framwork uses pinvoke with a COM interop component, Microsoft Chart Controls has DirectorySeparator issues, and the EntityFramwork namespace is not ported to mono, yet.
So note that when Microsoft says "works with mono", they mean "with mono on Windows".
It is estimated that the EntityFramwork port will take 1 year at least, until it reaches alpha/beta stage, that is, if somebody would decide to do that.
But there are no official plans to port EntityFramework.
EntityFramwork might work/s on the windows version of mono, as long as you set localcopy to true.
I advise you to use nhibernate instead.
Update:
As of Mono 2.11.3, Microsoft has open sourced EntityFramework.
Hence, it is now a part of Mono's distribution.
This version comes with 349 commits, with around 514 file changes.
It includes 15553 insertions
and 3717 deletions.
Two down, one to go.
I guess this means:
BIG THANKS TO MICROSOFT, THAT 'S TERRIFIC ! ! !

You should set CopyLocal = true for the System.Data.Entity assembly as well. You noted that you copied System.Web.MVC local, but never mentioned that you copied System.Data.Entity locally. You might also need to copy local any of the assemblies that System.Data.Entity depends upon that are not part of Mono.

It looks like there is no support in Mono for EDF at the moment, but someone is working on it.

Related

aspnet core 1.0 full .net framework on Linux

I have a few simple questions:
a) can I use mono on linux and osx to load the full .net framework like I would on windows by adding net46 to my project.json?
b) can I use mono as an alias like net46?
c) can I use mono with aspnet core 1.0 rtm projects on linux?
I have been looking at the dotnet docs, specifically the standard library and the table and the table with the platform support confuses me with the arrows and star under mono.
thanks
can I use mono on linux and osx to load the full .net framework like I would on windows by adding net46 to my project.json?
In theory, yes, that's exactly what you do: specify some version of net inside frameworks in your project.json and dotnet run will then use mono to run your application.
In practice, basic Hello World application works, but I'm not sure how well will more complicated applications work.
If you want to run dotnet build on the same machine, you will also need reference assemblies. The version I tested (mono 4.2.1) only contained reference assemblies up to .Net 4.5.1, so net451 works, but net46 doesn't.
can I use mono as an alias like net46?
I don't think you can, at least not without forking .Net Core SDK.
I don't understand why would you want to do that, but I believe doing so would require modifying DefaultFrameworkMappings in NuGet.Client.
can I use mono with aspnet core 1.0 rtm projects on linux?
I wasn't able to make a basic ASP.NET Core application run under mono. I don't know what the problem is, or how hard would it be to fix it. EDIT: I managed to work around the issue I encountered.
Mono is other thing. Yeah they developed mono like .net framework but you cannot use .net 4.6 on mono.
Read the following article. Click here
Micrsoft developed .net core a new framework to run .net on windows, linux, mac osx etc.

Can't reference an F# class library

This issue is exactly as described in the title.
I have a portable F# class library. I have created an ASP.NET Core Web Application (both .NET Framework and .NET Core), from which I have tried to add a reference to my F# class library.
Trying to add the reference gives a message:
The following projects are not supported as references:
Project type is unsupported by current project and can not (sic) be referenced.
This is extremely disappointing, as the .NET Core is now in General Availability.
Are there any workarounds while this bug gets addressed?
I have a project, which I started with Beta8 bits of .net core and since then I have an F# library, which I use from an asp.net core C# app. (btw here is an RC2 based minimal sample for referencing the F# lib from a net core based console app)
Here is how I did it:
Currently (according to my knowledge) there is no template in VS to create a coreCLR based F# library (the PLC templates under F# are all Full framework based, but that you still cannot reference from asp.net core even if it runs on full framework), so you have to do this with the command line. This is done by:
dotnet new --lang F#
This creates you a hello world coreCLR F# app. You can turn the app into a class library by modifying project.json file.
If you have a VS solution and you click to “Add” -> “Existing project” you can select the project.json file. This way you add it to your solution (and btw. an xproj file will be also created).
So at this point you will have the coreCLR based F# project in your solution. I believe by right clicking the asp.net core project and go to “Add” -> “Reference” -> Projects->Solutions and selecting the F# library you can already reference it. If this does not work, you can do it manually: just list the F# project under the “dependencies” in the project.json of the asp.net core application.
If your asp.net core app runs on full framework still need to do these steps. It actually doesn't really matter.
Now the bad part:
In the RTM (released on Monday) the “dotnet new” command creates an uncompliable F# app, because of some dependency issues. This is tracked here (the title says "on macOS", but it's the same on Windows) and as soon as it’s solved this should be fine (or if you did not yet install RTM and you have RC2 you are also good).
Intellisense and debugging across F# and C# does not work (I posted it here)
Although .NET Core has officially been released, the vast majority of the nuget packages in the ASP.NET Core Web Application are in prerelease. Moreover, although the entity framework identity model has been cleaned up, my attempt to change the key columns for users and roles from strings to ints generated an obscure error when I tried to implement Entity Framework migrations. I know I can do it for a .NET Web Application, even though the process is clunky in places. So for now I have gone back to using a .NET Framework Web Application. I'm looking forward to seeing a fully mature version of ASP.NET Core Web Applications. It's not ready, but it looks very promising.

Unable to utilize Entity Framework after deployment

i m using publish option for my project using Entity framework.
the 'bin' of the published folder does contain the dll of project that has Entity framework but the features of my application (using EF) stop working when they Get / Insert Data using Entity Framework .
the error is as follows in my application's File log:
02/01/2015 10:25:36 AM|TraceError |Exception is :The specified store provider cannot be found in the configuration, or is not valid.| |<EOL>
Am i missing any thing? ... Please help.
This might be happening due to system architecture of processors (32 bit and 64 bit versions of dll).
Try the following steps.
Open Inetmgr (IIS).
Go to application pools.
Open advance properties of the application pool on which your application is running.
Set Enable 32 bit Applications (in general category) to True.
I think this will solve your issue.
If you are using an Oracle database, I assume you must have installed the ODP.NET components. Unless you are using a third party provider such as Devart, which offers direct access to Oracle with its DirectConnect feature, there has to be a middle layer that the developer installs which would translate EF to Oracle. (Even if you used a third party provider, then you must have installed that third party provider on your development environment). Long story short, your VM does not have the provider that your developer PC has. You need to find out if you are using ODP.NET or a third party provider on your development PC, (which, I guarantee you, does not come with any Visual Studio or framework installation, somebody has to install it separately), then install it on your VM

.NET service fails with error 1053 on Windows Server 2003 r2 sp2

We have a set of .net 2.0 windows services installed on Windows Server 2003 R2 machine. They are configured to start as Local System account and start mode is Auto. All services are fail with error 1053 "The service did not respond to the start or control request in a timely fashion".
I've inserted logging to one of services and investigated that problem is outside our code. No single line of code executed.
It seems that problem with .net code permissions on the machine. But problem reproduces only on client machine (two different client with identical symptoms). On our developer and tester enviroment we can't reproduce it.
System to reproduce: OS: Windows Server 2003 R2 SP2 32bit clean install + product prerequisites: SQL Server 2005 Express SP2, .NET Framework 2 SP2 + our product
What can it be, any sugessions?
update from 07/04/2011:
File with ProcessMonitor log from the client machine: http://dl.dropbox.com/u/8982352/Logfile.zip
Service process name is: ParsecServiceHost.exe
Finally, reporting an answer, that microsoft support helped to get:
This problem occurs because a .NET Framework 2.0 managed assembly that
has an Authenticode signature takes longer than usual to load. The
signature is always verified when the .NET Framework 2.0 managed
assembly that has an Authenticode signature is loaded.
Additionally, the .NET Framework 2.0 managed assembly may take longer
than usual to load because of various other settings. For example, the
.NET Framework 2.0 managed assembly may take longer than usual to load
because of the network configuration.
Here is Microsoft KB, that describes problem and provides hotfix to .NET Framework 2.0
But this hotfix does not fix the long load time problem, but adds ability to simply disable disable signature verification in .NET :) by setting generatePublisherEvidence parameter in app.config!
Note: if you have .NET Framework SP2 then hotfix is not needed, simply set generatePublisherEvidence parameter in app.config.
http://support.microsoft.com/kb/936707 - FIX: A .NET Framework 2.0
managed application that has an Authenticode signature takes longer
than usual to start.
To solve issue, you can use this configuration setting to disable signature verification in a .NET Framework 2.0 managed application. You can use this configuration setting in an application configuration file. To do this, add the following code to the
.exe.config file for the .NET Framework 2.0 managed application:
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
If your application is hosted in IIS, change one of the following:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet.config
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
Note: On x64 machines, you must also change one of the following:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet.config
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config
When the service runs without a problem on win 7 / vista then i think the problem is your code e.g. your OnStart() Method. Normally IO-Operations are not allowed in this method and be careful using threads in this method.
You should not declare any resources in the constructor of the service which are going to be used in the OnStart() method of the service. Basically, Constructor runs for the very first time then it holds the values to be used in the OnStart() but then after OnStop() the resources are released and then the same cant be used again. Just move all the instantiation code form the constructor to the OnStart() and It will run.
Here's a link from MSDN for your quick reference: http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.onstart.aspx
There could be one more issue in this. You could be using the debug build. Services dont run in the debug mode so You should use the release build in order to run the service.

Where can I find .NET v1.0.5000.0?

I've just been informed at my workplace that we have an application that is used in production that has stopped working. I'm searching as best I can to find where the source for the application is in our source control but without much luck. I'm really hoping that this isn't an application that was developed on a local machine and never checked into source control.
It seems that this application is very old and the original developer is long gone. In an attempt to find out more about this application I've used the .NET Reflector to have a look inside...and I've found that it references mscorlib, System, System.Data, System.Drawing, and System.Windows.Forms but all of them state that they are version 1.0.5000.0.
How is this possible? Could it be that this is an application that was developed against the .NET 1.0 framework and has lived in production ever since? Is it possible that if .NET 1.0 were installed on the machine that it might run or is .NET 3.5 backwards compatible.
Finding .NET v1.0.5000.0 will be a minor thing if I can find the source code for the app...but if not, I may need to figure out how to get this app running in our current environment...
Sounds like .NET 1.0 is indeed on your production box... pretty sure you can run as many versions of .NET as you want installed in parallel.
Samuel has already pointed out the download location for .NET 1.0, but one other thing that may help, if you can't find the source, is the File Disassembler plugin for .NET Reflector. Then you can disassemble the whole thing in one hit & get what should be working source code (albeit with ugly private variable names).
Good luck...
This is the download for 1.0a. The production server will have 1.0 installed otherwise the application wouldn't run. And if it is an ASP application, IIS is configured to have it run in its own 1.0 app pool.
Can you extract out the source code from reflector and see if that can be made compilable? Disclaimer: I expect this suggestion is fully as kooky as it sounds.

Resources