Mono MVC3 failed to map path - asp.net-mvc-3

I'm trying to get a MVC3 application working under mono, and everything was going well until I deployed to my server...
I'm currently getting:
Failed to map path '/projects/_ViewStart.cshtml'
System.InvalidOperationException: Failed to map path '/projects/_ViewStart.cshtml'
at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, Boolean allowCrossAppMapping) [0x00000] in <filename unknown>:0
at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.HostingEnvironment.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.DefaultVirtualPathProvider.FileExists (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.FileExistenceCache.FileExists (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.VirtualPathFactoryManager.PageExistsInVPP (System.String virtualPath, Boolean useCache) [0x00000] in <filename unknown>:0
at System.Web.WebPages.VirtualPathFactoryManager.PageExists (System.String virtualPath, Boolean useCache) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageExecutingBase.FileExists (System.String path, Boolean useCache) [0x00000] in <filename unknown>:0
at System.Web.WebPages.StartPage.GetStartPage (System.Web.WebPages.WebPageRenderingBase page, System.String fileName, IEnumerable`1 supportedExtensions) [0x00000] in <filename unknown>:0
at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x00000] in <filename unknown>:0
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19 () [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter (IResultFilter filter, System.Web.Mvc.ResultExecutingContext preContext, System.Func`1 continuation) [0x00000] in <filename unknown>:0
Errors. I can confirm that all the files and DLL's exist, but the path doesn't look right, surely it should be looking in the Views folder where things DO exist?
Is there some sort of setting I need to set to ensure that it looks in the correct Views location? I also notice there is no "~" character before the file path...
I've looked around the net and tried various solutions, but none seem to work..

Have a look into your Apache configuration, for me it said
Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_bla --applications /testmono:/var/www/ModMonoMvc3Application --nonstop (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
because I misunderstood the configuration option AddMonoApplications. It should read something like this:
# "default" is defined in mods-available/mod_mono.conf
AddMonoApplications default "/testmono:/var/www/ModMonoMvc3Application"
<Location /testmono/>
SetHandler mono
</Location>
I accidentally wrote "bla" instead of "default" because I thought it was the application name, but in fact it defines which server executable is started.

I was getting the same error when directly calling
HttpContext.Current.Server.MapPath("/") or
HttpContext.Current.Server.MapPath(Path.DirectorySeparatorChar.ToString())
However this works:
HttpContext.Current.Server.MapPath("~")

Related

Gtk Application Non-Consistant Execution using Xamarin Theme

I have a mkbundled mono app with mono embedded in it.i have created a standalone package from it using platypus.I use the following to load the Mac Theme(Xamarin)
Gtk.Rc.Parse ("Default/gtkrc");
The theme is the Xamarin theme from share/theme/xamarin
The thing is that the application does not launch consitantly when using this theme.It launches randomly.Also im using gtk-button-images = 1 in theme file to show the buttons.The app works fine with other themes.
What is the problem here?please help.
UPDATE:
I have tried launching the application manually from console by putting
the following ./script.sh
It launches the program sometimes. Otherwise the console stays there with no output.I have the program window icon on the dock during this ,When i close it i can see the following output on the console
./script.sh: line 3: 830 Terminated: 15 ./myapp
The contents in the script are as follows
VAR=`pwd`
export DYLD_FALLBACK_LIBRARY_PATH="$VAR/lib:/usr/lib"
./myapp
On Random successful execution of the program and only upon closing the program.I get the following on the console
Gtk-WARNING **: Can't set a parent on a toplevel widget
Unhandled Exception:
System.MissingMethodException: No constructor found for MonoMac.Foundation.NSObject+MonoMac_Disposer::.ctor(System.IntPtr)
at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0
at MonoMac.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in <filename unknown>:0
at MonoMac.ObjCRuntime.NSObjectMarshaler`1[MonoMac.Foundation.NSObject].MarshalNativeToManaged (IntPtr handle) [0x00000] in <filename unknown>:0
at (wrapper native-to-managed) object:[MonoMac.Foundation.NSObject:IntPtr NativeRetain()] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector)
at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging:void_objc_msgSend_intptr_intptr_bool (intptr,intptr,intptr,intptr,bool)
at MonoMac.Foundation.NSObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at MonoMac.Foundation.NSObject.Finalize () [0x00000] in <filename unknown>:0
Im stuck here.Please help me.

Deploying ASP.NET 5 app to EC2 in a Docker container

I have a t2.micro EC2 instance running Amazon Linux AMI 2015.03.1. I installed docker on it, but then also updated it manually. Finally, I made the docker daemon listen on a port of my choosing so I could publish to it remotely.
On my development machine, I added to my VS2015 install the VS2015 Tools for Docker - August Preview. I added a new ASP.NET 5 Web Application, built it and hit publish. The container makes it to the host, but it never runs because of this exception;
System.TypeLoadException: Could not load type 'Microsoft.Framework.Configuration.IConfigurationRoot' from assembly 'Microsoft.Framework.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain (Microsoft.Dnx.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args, IRuntimeEnvironment env, System.Runtime.Versioning.FrameworkName targetFramework) [0x00000] in <filename unknown>:0
This was an issue due to multiple projects references different versions of ASP.NET5 - ie; beta7 & beta6.
Ensuring only one stream was referenced in all project.json's resolved this issue.

Error when try to use EntityFramework 7 + SQLite on OSX

I'm try to use EntityFramework 7 + SQLite on a sample App with .Net Core on a Mac OSX environment. I have installed the Mono 4.0.2 and .Net Version Manager, this is my "dnvm list" command result:
1.0.0-beta7-12274 coreclr x64 darwin
1.0.0-beta6 mono linux/darwin default
1.0.0-beta7-12274 mono linux/darwin
* 1.0.0-beta7-12275 mono linux/darwin
When a try to execute some EntityFramework.Command, the follow problem occurs:
System.TypeLoadException: Could not load type 'Microsoft.Framework.Runtime.ILibraryInformation' from assembly 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
The full stack is:
System.TypeLoadException: Could not load type 'Microsoft.Framework.Runtime.ILibraryInformation' from assembly 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Microsoft.Data.Entity.Commands.Program.Execute (System.String startupProject, System.Func1 invoke) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program.AddMigration (System.String name, System.String context, System.String startupProject) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program+<>c__DisplayClass10_1.<Main>b__7 () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List1 args, IRuntimeEnvironment env, System.Runtime.Versioning.FrameworkName targetFramework) [0x00000] in :0
ILibraryInformation was renamed recently, and the DNX beta7 you're using probably includes this change: make sure to also reference recent beta7 packages in your project.json file.
You can use the wildcard to reference the latest version:
"dependencies": {
"EntityFramework.Sqlite": "7.0.0-*"
}
Because of project renames, nightly builds are currently broken. To use just beta6, you may need to try these steps:
Remove ~/.dnx/packages. Some of these may contain a mix of post- and pre-rename references.
Ensure you are not using the nightly nuget feed (myget.org)
dnvm use 1.0.0-beta6
Make sure you are using "EntityFramework.Commands": "7.0.0-beta6" and "EntityFramework.Sqlite": "7.0.0-beta6" in project.json.
Follow the Workarounds in the Getting Started on OS X guide.

WebSharper error when building under Mac OS X

I'm trying to build a project using WebSharper under Mac OSX and I got the following error :
Target WebSharperCompile:
Compiling with WebSharper..
/Volumes/Data/Dev/Landmark_tools/packages/WebSharper.2.5.125.62/build/WebSharper.targets: error : Non-negative number required.
Parameter name: srcOffset at System.Buffer.BlockCopy (System.Array src, Int32 srcOffset, System.Array dst, Int32 dstOffset, Int32 count) [0x00000] in <filename unknown>:0
at Mono.Cecil.PE.Image.GetDebugHeader (System.Byte[]& header) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.GetDebugHeader (System.Byte[]& header) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ProcessDebugHeader () [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadSymbols (ISymbolReader reader) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at IntelliFactory.WebSharper.Compiler.Loader.load (Microsoft.FSharp.Core.FSharpOption`1 flp, System.Byte[] bytes, Microsoft.FSharp.Core.FSharpOption`1 symbols, IntelliFactory.Core.AssemblyResolver aR) [0x00000] in <filename unknown>:0
at IntelliFactory.WebSharper.Compiler.Loader.LoadFile (System.String path) [0x00000] in <filename unknown>:0
Task "WebSharperTask" execution -- FAILED
Done building target "WebSharperCompile" in project "/Volumes/Data/Dev/Landmark_tools/RegionsInfo/RegionsInfo.fsproj".-- FAILED
Done building project "/Volumes/Data/Dev/Landmark_tools/RegionsInfo/RegionsInfo.fsproj".-- FAILED
Build FAILED.
Errors:
/Volumes/Data/Dev/Landmark_tools/RegionsInfo/RegionsInfo.fsproj (default targets) ->
/Volumes/Data/Dev/Landmark_tools/packages/WebSharper.2.5.125.62/build/WebSharper.targets (WebSharperCompile target) ->
/Volumes/Data/Dev/Landmark_tools/packages/WebSharper.2.5.125.62/build/WebSharper.targets: error : Non-negative number required.
Parameter name: srcOffset at System.Buffer.BlockCopy (System.Array src, Int32 srcOffset, System.Array dst, Int32 dstOffset, Int32 count) [0x00000] in <filename unknown>:0
at Mono.Cecil.PE.Image.GetDebugHeader (System.Byte[]& header) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.GetDebugHeader (System.Byte[]& header) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ProcessDebugHeader () [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadSymbols (ISymbolReader reader) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0
at IntelliFactory.WebSharper.Compiler.Loader.load (Microsoft.FSharp.Core.FSharpOption`1 flp, System.Byte[] bytes, Microsoft.FSharp.Core.FSharpOption`1 symbols, IntelliFactory.Core.AssemblyResolver aR) [0x00000] in <filename unknown>:0
at IntelliFactory.WebSharper.Compiler.Loader.LoadFile (System.String path) [0x00000] in <filename unknown>:0
0 Warning(s)
1 Error(s)
I can build the same project under Windows without any problems.
Under windows I can simply do msbuild or specify a configuration msbuild /p:Configuration=Release or even the Fake compiler.
And under Mac OSX whatever I try to use (using xbuild or Fake) I always got the same error. Last time I had that I was able to build the project using Release mode but here it's not working either.
I have hosted the project under github : https://github.com/MangelMaxime/BugReport
I know it's not recommended but better to have the same conditions...
Looks like a Cecil bug that was recently fixed: "Non-negative number required" trying to read f# dll

Unable to get string values from .Resx file within Monodevelop on Mac OSX

From this question :
C#, Localization, Resources, and MonoDevelop
In the answers part it says :
"The usual thing is to store your resources in .resx form in the project, and MonoDevelop will automatically compile them into .resources files when building your project (you'd have to compile .txt files manually). Unfortunately MD doesn't have special editing tools for resx files, so you'd have to edit the XML directly."
I have a Application that works on Windows with vs2008.
I am trying to port it to Mac OSX.
I have a .resx file that contains different strings.
When I use:
Resources.Properties.Resources.Distributor_ARDL
I get :
{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OverflowException: Number overflow. at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int) at System.Drawing.Icon.InitFromStreamWithSize (System.IO.Stream stream, Int32 width, Int32 height) [0x00000] in :0 at System.Drawing.Icon..ctor (System.Runtime.Serialization.SerializationInfo info, StreamingContext context) [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at System.Runtime.Serialization.ObjectRecord.LoadData (System.Runtime.Serialization.ObjectManager manager, ISurrogateSelector selector, StreamingContext context) [0x00000] in :0 at System.Runtime.Serialization.ObjectManager.DoFixups () [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (BinaryElement elem, System.IO.BinaryReader reader, Boolean readHeaders, System.Object& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000] in :0 at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in :0 at System.Resources.ResourceReader.ReadNonPredefinedValue (System.Type exp_type) [0x00000] in :0 at System.Resources.ResourceReader.ReadValueVer2 (Int32 type_index) [0x00000] in :0 at System.Resources.ResourceReader.LoadResourceValues (.ResourceCacheItem[] store) [0x00000] in :0 at System.Resources.ResourceReader+ResourceEnumerator.FillCache () [0x00000] in :0 at System.Resources.ResourceReader+ResourceEnumerator..ctor (System.Resources.ResourceReader readerToEnumerate) [0x00000] in :0 at System.Resources.ResourceReader.GetEnumerator () [0x00000] in :0 at System.Resources.ResourceSet.ReadResources () [0x00000] in :0 at System.Resources.ResourceSet.GetObjectInternal (System.String name, Boolean ignoreCase) [0x00000] in :0 at System.Resources.ResourceSet.GetObject (System.String name, Boolean ignoreCase) [0x00000] in :0 at System.Resources.RuntimeResourceSet.GetObject (System.String name, Boolean ignoreCase) [0x00000] in :0 at System.Resources.ResourceSet.GetStringInternal (System.String name, Boolean ignoreCase) [0x00000] in :0 at System.Resources.ResourceSet.GetString (System.String name, Boolean ignoreCase) [0x00000] in :0 at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x00000] in :0 at Imaginality.Resources.Properties.Resources.get_Distributor_ARDL () [0x00000] in
So I am wondering if the resx file is working properly. If anyone else has had any luck with this problem.
The build option for the resx is set to embeddedresouce.
Hi after some mucking around I found that mono did not like a couple of .icon files I had created. As of this time I am not sure what it didnt like (as it did like 3 out of 8) so once I removed the files it built fine. It took a bit of time to see which they were as the error is not related to the icon files just the first call to the Resourced file.
Cheers

Resources