I was using Plugin.FilePicker to pick files from the device. It was working fine on android version 11 and below. But on android version 12 and above, it is breaking with below exception:
Java.Lang.NullPointerException: uri
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00088] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/JniEnvironment.g.cs:11928
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001e] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:894
at Android.Content.ContentResolver.Query (Android.Net.Uri uri, System.String[] projection, System.String selection, System.String[] selectionArgs, System.String sortOrder) [0x000a0] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Android.Content.ContentResolver.cs:1456
at Plugin.FilePicker.IOUtil.GetDataColumn (Android.Content.Context context, Android.Net.Uri uri, System.String selection, System.String[] selectionArgs) [0x00013] in D:\a\1\s\src\Plugin.FilePicker\Android\IOUtil.android.cs:151
at Plugin.FilePicker.IOUtil.GetPath (Android.Content.Context context, Android.Net.Uri uri) [0x00167] in D:\a\1\s\src\Plugin.FilePicker\Android\IOUtil.android.cs:108
at Plugin.FilePicker.FilePickerActivity.OnActivityResult (System.Int32 requestCode, Android.App.Result resultCode, Android.Content.Intent data) [0x00039] in D:\a\1\s\src\Plugin.FilePicker\Android\FilePickerActivity.android.cs:151
--- End of stack trace from previous location where exception was thrown ---
at Plugin.FilePicker.FilePickerImplementation.PickFile (System.String[] allowedTypes) [0x00028] in D:\a\1\s\src\Plugin.FilePicker\Android\FilePickerImplementation.android.cs:60
at CatholicBrain.ConnectAppModule.CreateActivityPage.PickFile (System.Object sender, System.EventArgs args) [0x00075] in :0
--- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: uri
at java.util.Objects.requireNonNull(Objects.java:245)
at android.content.ContentResolver.query(ContentResolver.java:1225)
at android.content.ContentResolver.query(ContentResolver.java:1184)
at android.content.ContentResolver.query(ContentResolver.java:1140)
at crc64424a8adc5a1fbe28.FilePickerActivity.n_onActivityResult(Native Method)
at crc64424a8adc5a1fbe28.FilePickerActivity.onActivityResult(FilePickerActivity.java:48)
at android.app.Activity.dispatchActivityResult(Activity.java:8840)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5694)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5740)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2458)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:334)
at android.app.ActivityThread.main(ActivityThread.java:8501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
I checked for any updates for Plugin.FilePicker and found that the package is deprecated. So I installed the Xamarin.Essentials package and updated codes for picking files. It is working fine on android version 12 and above.
Xamarin.Essentials.FileResult file = null;
file = await FilePicker.PickAsync();
if (file != null)
{
filename_label.IsVisible = true;
filename_label.Text = file.FileName;
upload_layout.IsVisible = true;
}
But when I try to upload the file using our REST API it fails with below exception:
System.IO.FileNotFoundException: hail-mary.pdf
File name: 'hail-mary.pdf' ---> Java.IO.FileNotFoundException: hail-mary.pdf
at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00068] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/JniEnvironment.g.cs:11524
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001e] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:848
at Android.Content.Res.AssetManager.Open (System.String fileName) [0x0001f] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Android.Content.Res.AssetManager.cs:265
at Xamarin.Essentials.FileSystem.PlatformOpenAppPackageFileAsync (System.String filename) [0x0001d] in D:\a_work\1\s\Xamarin.Essentials\FileSystem\FileSystem.android.cs:48
--- End of managed Java.IO.FileNotFoundException stack trace ---
java.io.FileNotFoundException: hail-mary.pdf
at android.content.res.AssetManager.nativeOpenAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:893)
at android.content.res.AssetManager.open(AssetManager.java:870)
at crc64ee486da937c010f4.ButtonRenderer.n_onClick(Native Method)
at crc64ee486da937c010f4.ButtonRenderer.onClick(ButtonRenderer.java:107)
at android.view.View.performClick(View.java:7512)
at android.view.View.performClickInternal(View.java:7489)
at android.view.View.access$3700(View.java:857)
at android.view.View$PerformClick.run(View.java:29034)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:334)
at android.app.ActivityThread.main(ActivityThread.java:8501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
at Xamarin.Essentials.FileSystem.PlatformOpenAppPackageFileAsync (System.String filename) [0x00036] in D:\a_work\1\s\Xamarin.Essentials\FileSystem\FileSystem.android.cs:52
at Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync (System.String filename) [0x00000] in D:\a_work\1\s\Xamarin.Essentials\FileSystem\FileSystem.shared.cs:16
at CatholicBrain.ConnectAppModule.CreateActivityPage.UploadFile (System.Object sender, System.EventArgs e) [0x00126] in <8fb254ba200e4d369cb3f96cc3e665ff>:0
Upload Code:
var content = new MultipartFormDataContent();
Stream stream = await FileSystem.OpenAppPackageFileAsync(file.FileName);
byte[] data;
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
data = ms.ToArray();
ms.Dispose();
}
content.Add(new StreamContent(stream), "\"fileUpload\"", $"\"{file.FullPath}\"");
var httpClient = new HttpClient();
var response = await httpClient.PostAsync(new Uri(REST API Path), content);
file.FullPath is provided on the upload code but getting FileNotFoundException.
If you use FilePicker.PickAsync(); to get the file, you do not need to use Stream stream = await FileSystem.OpenAppPackageFileAsync(file.FullPath); to read it to stream.
Just use Stream stream = await file.OpenReadAsync(); directly, then you can get the stream.
Related
I'm using a custom renderer on a WebView in my project, and I need it to be able to open popups, then I added JavaScriptCanOpenWindowsAutomatically settings to the constructor, but if I set it to true the app crashes at launch, here is my renderer:
[assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(HybridWebViewRenderer))]
namespace ClotureSiadForms.Droid.Renderer
{
internal class HybridWebViewRenderer : WebViewRenderer
{
public HybridWebViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Settings.JavaScriptEnabled = true;
Control.Settings.DomStorageEnabled = true;
Control.Settings.SavePassword = true;
//Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
}
}
}
}
And the error:
10-19 19:05:55.667 HUAWEI RNE-L21 Error 24197 mono-rt [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Types' threw an exception. ---> System.EntryPointNotFoundException: java_interop_jvm_list assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jvm_list(intptr[],int,int&)
at Java.Interop.JniRuntime.GetCreatedJavaVMs (System.IntPtr[] handles, System.Int32 bufLen, System.Int32& nVMs) [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniRuntime.GetAvailableInvocationPointers () [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniRuntime.get_CurrentRuntime () [0x00095] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironmentInfo..ctor () [0x00006] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+<>c.<.cctor>b__35_0 () [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at System.Threading.ThreadLocal`1[T].GetValueSlow () [0x00031] in <a790ddc2dda1484d9a4b87dd85c6ca47>:0
at System.Threading.ThreadLocal`1[T].get_Value () [0x0003e] in <a790ddc2dda1484d9a4b87dd85c6ca47>:0
at Java.Interop.JniEnvironment+Types.TryFindClass (System.String classname, System.Boolean throwOnError) [0x00014] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00000] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
at Java.Interop.JniEnvironment+Types..cctor () [0x000d2] in <d12ba608ed5a4079a11cd8a7188dddcf>:0
--- End of inner exception stack trace ---
at Android.Runtime.JNIEnv.IsInstanceOf (System.IntPtr obj, System.IntPtr clazz) [0x0000e] in <ac4226d0aad24df781f4097e7b8b972f>:0
at Android.Runtime.JNIEnv.IsGCUserPeer (System.IntPtr value) [0x0000f] in <ac4226d0aad24df781f4097e7b8b972f>:0
Then, is there another way to make blank links open in the default browser ? Or to prevent this error ?
StackTrace:
NavigationRenderer+ParentingViewController.Dispose (System.Boolean disposing)
NSObject.Dispose ()
NavigationRenderer.Dispose (System.Boolean disposing)
NSObject.Dispose ()
DisposeHelpers.DisposeModalAndChildRenderers (Xamarin.Forms.Element view)
IDisposable.Dispose ()
FormsApplicationDelegate.UpdateMainPage ()
FormsApplicationDelegate.ApplicationOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args)
BindableObject.OnPropertyChanged (System.String propertyName)
Element.OnPropertyChanged (System.String propertyName)
Application.set_MainPage (Xamarin.Forms.Page value)
PageModelCoreMethods.SwitchOutRootNavigation (System.String navigationServiceName)
BasePageModel.<NavigateToLoginPage>b__74_0 () // I think the problem is in this method
NSAsyncActionDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)
This is the stack trace for a SIGABRT crash I'm getting in my iOS app using Xamarin.Forms 4.4.
I think the issue is coming from this method:
async protected virtual Task<bool> NavigateToLoginPage()
{
await LoginProvider.Clear();
Platform.BeginInvokeOnMainThread( () =>
{
CoreMethods.SwitchOutRootNavigation(CoreApp.LoginNavigationStack);
});
return true;
}
because it's the last method that was called before the crashing II'm assuming but I'm not sure how to fix it. I've looked at some solutions online like:
MonoTouch SIGSEGV crash using navigationcontroller and searchdisplaycontroller and https://forums.xamarin.com/discussion/6546/finding-the-cause-of-sigsegv which I think are related, but they don't match my case exactly..
Does anybody know what to do about this?
Thanks!
I use below code to access SAP Odata WebService:
string strUrl = "https://...../HandlingUnitSet?$format=json";
var credentials = new NetworkCredential("user", "usr123");
var handler = new HttpClientHandler { Credentials = credentials };
var client = new System.Net.Http.HttpClient(handler);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("Accept", "application/json");
var response = await client.GetAsync(strUrl);
string status = response.StatusCode.ToString();
string header = response.Headers.ToString();
string cont = response.Content.ToString();
string contactsJson = response.Content.ReadAsStringAsync().Result;
UoUnit ObjUnitList = new UoUnit();
ObjUnitList = JsonConvert.DeserializeObject<UoUnit>(contactsJson);
The Problem : I got the below error message
The url suppose to return Json Data but I did not get it. This error encountered at the line of DeserializeObject
Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue ()
{Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x0004a] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <d32db49e5e3440729da31845c03ddc3a>:0
}
I have the following POST edit action method:-
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(RackJoin rj,FormCollection formValues)
{
try
{
if (ModelState.IsValid)
{
repository.InsertOrUpdateRack(rj.Rack, User.Identity.Name, rj.Resource.RESOURCEID);
repository.Save();
return RedirectToAction("Index");
}
}
catch (DbUpdateConcurrencyException ex)
{
var entry = ex.Entries.Single();
var databaseValues = (Rack)entry.GetDatabaseValues().ToObject();
var clientValues = (Rack)entry.Entity;
var entry2 = ex.Entries.Single();
var databaseValues2 = (Resource)entry2.GetDatabaseValues().ToObject();
var clientValues2 = (Resource)entry2.Entity;
if (databaseValues.RU != clientValues.RU)
ModelState.AddModelError("Rack.RU", "Current value: "
+ databaseValues.RU);
but when the DbUpdateConcurrencyException exception is raised i am getting the following exception on the following line of code var databaseValues2 = (Resource)entry2.GetDatabaseValues().ToObject();:-
Unable to cast object of type 'System.Data.Entity.DynamicProxies.Rack_81556130B3DB7E3D4F63B9FF3F15832A81A86055EED840211E95A71E1342027D' to type 'TMS.Models.Resource'.
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.InvalidCastException: Unable to cast object of type 'System.Data.Entity.DynamicProxies.Rack_81556130B3DB7E3D4F63B9FF3F15832A81A86055EED840211E95A71E1342027D' to type 'TMS.Models.Resource'.
Source Error:
Line 175: var clientValues = (Rack)entry.Entity;
Line 176: var entry2 = ex.Entries.Single();
Line 177: var databaseValues2 = (Resource)entry2.GetDatabaseValues().ToObject();
Line 178: var clientValues2 = (Resource)entry2.Entity;
Line 179:
Source File: c:\Users\Administrator\Documents\Visual Studio 2012\Projects\TMS\TMS\Controllers\RackController.cs Line: 177
Stack Trace:
[InvalidCastException: Unable to cast object of type 'System.Data.Entity.DynamicProxies.Rack_81556130B3DB7E3D4F63B9FF3F15832A81A86055EED840211E95A71E1342027D' to type 'TMS.Models.Resource'.]
TMS.Controllers.RackController.Edit(RackJoin rj, FormCollection formValues) in c:\Users\Administrator\Documents\Visual Studio 2012\Projects\TMS\TMS\Controllers\RackController.cs:177
lambda_method(Closure , ControllerBase , Object[] ) +245
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +59
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +435
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +60
System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +50
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +75
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +44
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +139
I'm not entirely clear what's going on in this section of code, are you meant to be retrieving the Resource from the second context you mentioned in your comment?
var entry = ex.Entries.Single();
var databaseValues = (Rack)entry.GetDatabaseValues().ToObject();
var clientValues = (Rack)entry.Entity;
var entry2 = ex.Entries.Single();
var databaseValues2 = (Resource)entry2.GetDatabaseValues().ToObject();
var clientValues2 = (Resource)entry2.Entity;
If you called Single() on a sequence that contained more than one element, you would generate an exception; since Single isn't generating an exception, you only have one entry present which you're using in both cases.
In the first you want to treat it as a Rack, which doesn't seem to generate a complaint. In the second, you're treating it as a Resource, which seems to be incompatible with Rack, the cause of your complaint.
InvalidCastException: Unable to cast object of type 'System.Data.Entity.DynamicProxies.Rack_81...' to type 'TMS.Models.Resource'.]
The reason your exception only contains that particular entity may well be found in your InsertOrUpdateRack method.
This is the error I get when I start my ASP.NET application in Mono:
System.InvalidOperationException: The process must exit before getting the requested information.
at System.Diagnostics.Process.get_ExitCode () [0x00044] in /usr/src/mono-2.6.3/mcs/class/System/System.Diagnostics/Process.cs:149
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x001ee] in /usr/src/mono-2.6.3/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:267
at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00011] in /usr/src/mono-2.6.3/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:156
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in /usr/src/mono-2.6.3/mcs/class/System/System.CodeDom.Compiler/CodeDomProvider.cs:119
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x0022f] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:804
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:730
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00254] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:624
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:411
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00050] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:356
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x0003a] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:803
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.Web.VirtualPath virtualPath, System.Type requiredBaseType) [0x0000c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:500
at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x0001c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.UI/PageParser.cs:161
at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs:45
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00055] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1643
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1624
at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x0075f] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1259
I checked the source code indicated by the stacktrace, namely :CSharpCodeCompiler.cs:267
mcs.WaitForExit();
result.NativeCompilerReturnValue = mcs.ExitCode; //this throws the exception
I have no ideea if this is a bug in Mono, or if my App is doing something it shoudn't.
A simple "Hello World" application indicates that Mono is properly installed and working, It is just my app that is causing this exception to be thrown.
Hoping some enlighted minds have more on the issue
I'm runing Apache + mod_mono 2.6.3 on a CentOS 5.4 server.
What seems to make the difference between a simple "Hello World" and my application, is that there is a TON of stuff going on in Global.asax's Application_Start(). There are TCP sockets opened (and closed), tens of new threads spawned (arround 80) and various services started and closed. In a normal Windows + IIS server, the App would take up to 30 seconds to start. Why would this make a difference in Mono though ?
Edit:
Interestingly enough, one way to circumvent this problem is to move ALL the code from Application_Start into a separate async process:
void Application_Start()
{
var t = new System.Threading.Thread(new ThreadStart(this.Async_Application_Start));
t.Start();
}
void Async_Application_Start()
{
... Lots of stuff going on here..
log('Async Application Start is done!'); // this actually gets logged, so the code DOES execute and end
}
Try to look at this post.