I'm working on a Xamarin forms application and not sure if this is an error triggered by C#/HttpClient or by Xamarin Forms.
In my Xamarin Forms application, I have a RequestService class that contains the following code:
public class RequestService : IRequestService
{
private static HttpClient instance;
private static HttpClient HttpClientInstance => instance ?? (instance = new HttpClient(new NativeMessageHandler() { EnableUntrustedCertificates = true, DisableCaching = true }));
public async Task<TResult> GetAsync<TResult>(string uri, string token = "")
{
setupHttpClient(token);
HttpResponseMessage response = await HttpClientInstance.GetAsync(uri).ConfigureAwait(false);
await HandleResponse(response);
string responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return await Task.Run(() => JsonConvert.DeserializeObject<TResult>(responseData));
}
private void setupHttpClient(string token = "")
{
HttpClientInstance.DefaultRequestHeaders.Accept.Clear();
HttpClientInstance.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (!string.IsNullOrWhiteSpace(token))
{
HttpClientInstance.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", token);
}
}
private async Task HandleResponse(HttpResponseMessage response)
{
if (!response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == HttpStatusCode.Unauthorized)
{
throw new Exception(content);
}
throw new HttpRequestException(content);
}
}
}
It has been working quite well for the last 5 to 7 days but today it started crashing without any errors.Any request just exits the application.
I managed to debug and trace successful execution until the line:
HttpResponseMessage response = await HttpClientInstance.GetAsync(uri).ConfigureAwait(false);
It is on this line that it tries to do something and then just exits the app. The Debug console for that line shows the following:
Thread started: #3
05-14 10:20:51.974 D/Mono (20217): Assembly Ref addref ModernHttpClient[0x7028fef180] -> System[0x701365c000]: 15
05-14 10:20:51.986 D/Mono (20217): Assembly Ref addref ModernHttpClient[0x7028fef180] -> System.Core[0x701439c500]: 10
05-14 10:20:52.098 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.098 D/Mono (20217): Searching for 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.098 D/Mono (20217): Probing 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.098 D/Mono (20217): Found as 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.101 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.101 D/Mono (20217): Searching for 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.101 D/Mono (20217): Probing 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.101 D/Mono (20217): Found as 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.107 D/Mono (20217): Searching for 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): Probing 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): Found as 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.213 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.214 D/Mono (20217): Searching for 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.214 D/Mono (20217): Probing 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.214 D/Mono (20217): Found as 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.348 F/ (20217): /Users/builder/jenkins/workspace/xamarin-android-d15-6/xamarin-android/external/mono/mono/mini/debugger-agent.c:4846: (null) assembly:mscorlib.dll type:BadImageFormatException member:<none>
05-14 10:20:52.354 F/libc (20217): Fatal signal 6 (SIGABRT), code -6 in tid 20217 (com.companyname.appname), pid 20217 (com.companyname.appname)
A few things to note here are as follows:
I'm using ModernHttpClient
The settings under Android Project -> Properties -> Android Options -> are:
HttpClient Implementation = Android
SSL/TLD Implementation = Native TFS 1.2+
Has anybody come across this issue? Any assistance would be greatly appreciated.
Thanks
Ok! So this was solved by doing the following:
Upgrade to latest version of Xamarin forms.
Get rid of ModernHttpClient as it is not required any more due to point # 3.
The functionality of ModernHttpClient (i.e Native SSL/Tls) is now built into Xamarin and can now be configured at the platform level as per below links:
iOS - https://learn.microsoft.com/en-us/xamarin/cross-platform/macios/http-stack
Android - https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=windows
Related
I am using Xamarin.Forms 4.6 and the LibVLCsharp library to show videos on Android devices.
I ran some of the sample apps and got a couple to run but those sample apps are using Xamarin 3.2.
The problem is as soon as the Play method is called the app crashes hard and doesn't even throw an exception.
I get this in the output window:
06-19 12:37:29.044 D/ViewRootImpl#cb7f4a7MainActivity: ViewPostIme pointer 0
06-19 12:37:29.113 D/ViewRootImpl#cb7f4a7MainActivity: ViewPostIme pointer 1
06-19 12:37:29.128 D/Mono (10562): DllImport searching in: 'libvlc' ('libvlc.so').
06-19 12:37:29.128 D/Mono (10562): Searching for 'libvlc_media_player_play'.
06-19 12:37:29.128 D/Mono (10562): Probing 'libvlc_media_player_play'.
06-19 12:37:29.128 D/Mono (10562): Found as 'libvlc_media_player_play'.
06-19 12:37:29.129 D/Mono (10562): DllImport searching in: 'libvlc' ('libvlc.so').
06-19 12:37:29.129 D/Mono (10562): Searching for 'libvlc_media_player_get_media'.
06-19 12:37:29.129 D/Mono (10562): Probing 'libvlc_media_player_get_media'.
06-19 12:37:29.129 D/Mono (10562): Found as 'libvlc_media_player_get_media'.
Thread started: #11
06-19 12:37:29.166 D/Mono (10562): Requesting loading reference 5 (of 11) of /storage/emulated/0/Android/data/com.companyname.xamarintestapp/files/.override/LibVLCSharp.Forms.dll
06-19 12:37:29.166 D/Mono (10562): Loading reference 5 of /storage/emulated/0/Android/data/com.companyname.xamarintestapp/files/.override/LibVLCSharp.Forms.dll asmctx DEFAULT, looking for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
06-19 12:37:29.166 D/Mono (10562): Assembly Ref addref LibVLCSharp.Forms[0x7ab54d3e80] -> Java.Interop[0x7a9f22e800]: 14
=================================================================
Native Crash Reporting
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
No native Android stacktrace (see debuggerd output).
=================================================================
Basic Fault Address Reporting
Memory around native instruction pointer (0x7a90c94e68):0x7a90c94e58 20 8b 46 f9 ff 03 00 f9 e1 83 00 91 22 00 a0 72 .F........."..r
0x7a90c94e68 08 00 40 f9 33 00 a0 72 08 19 40 f9 00 01 3f d6 ..#.3..r..#...?.
0x7a90c94e78 a0 03 00 34 28 a9 00 b0 20 8b 46 f9 08 d9 1a 91 ...4(... .F.....
0x7a90c94e88 00 e4 00 6f 00 1d 08 4e f3 0b 00 b9 e0 03 81 3c ...o...N.......<
===================================================
Managed Stacktrace:
domain required for stack walk=================================================================
06-19 12:37:29.167 W/.xamarintestap(10562): 0xebadde09 skipped times: 0
06-19 12:37:29.170 F/libc (10562): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 10643 (Thread-17), pid 10562 (.xamarintestapp)
Anyone have any ideas on why this is happening? I attached a sample test to this post which demonstrates what I am seeing.
A link to the test app is here: http://www.filedropper.com/xamarintestapp2
Missing Core.Initialize() call
While trying to get back results from a separate thread, my app simply stops working and exits, with available information I've been able to write this code
public async override Task<IQueryable<Entry>> FindAsync(string inputText)
{
var resultingEntries = await Task.Run(() =>
{
// The heavy stuff starts here, in anew thread.
using (var realm = Realm.GetInstance(DbConfig))
{
// All data
var bgHaystack = realm.All<Entry>();
// Because realm doesn't support some of the LINQ operations on not stored fields (Content)
// the set of entries is converted to a IEnumerable.
IEnumerable<Entry> subset = bgHaystack;
// This is where the search gets actually done
subset = subset.Where(entry => entry.Content.ToLower().StartsWith(inputText));
// Extracts ids
var foundEntryIds = ExtractIdsFromEntries(subset);
// Select entries
var foundEntries = FindingManyMatches(bgHaystack, foundEntryIds.ToArray());
return ThreadSafeReference.Create(foundEntries);
}
});
var results = Realm.GetInstance(DbConfig).ResolveReference(resultingEntries);
return results;
}
And everything works just fine, except for the second to last line where I want to get the resulting object, do you have any idea on what's wrong here and how to solve this issue?
Stack trace:
Native Crash Reporting
=================================================================
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.
=================================================================
No native Android stacktrace (see debuggerd output).
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x7cdcb67c70):0x7cdcb67c60 c0 03 5f d6 c8 02 80 52 e0 03 08 2a c0 03 5f d6 .._....R...*.._.
0x7cdcb67c70 08 00 40 79 09 3d 0e 53 08 3d 00 12 69 01 00 35 ..#y.=.S.=..i..5
0x7cdcb67c80 09 01 13 12 2a 01 00 32 0b fc 5f 48 7f 21 29 6b ....*..2.._H.!)k
0x7cdcb67c90 a1 00 00 54 0a 7c 0b 48 8b ff ff 35 e0 03 1f 2a ...T.|.H...5...*
================================================
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_object_reference'.=================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at NativeMethods:resolve_query_reference <0x00007>
at Realms.SharedRealmHandle:ResolveReference <0x00243>
at Realms.Realm:ResolveReference <0x0008f>
at <FindAsync>d__9:MoveNext <0x0062f>
at MoveNextRunner:InvokeMoveNext <0x000f3>
at System.Threading.ExecutionContext:RunInternal <0x003af>
at System.Threading.ExecutionContext:Run <0x0006b>
at MoveNextRunner:Run <0x00193>
at <>c:<.cctor>b__7_0 <0x0009b>
at <>c__DisplayClass2_0:<Post>b__0 <0x00093>
at RunnableImplementor:Run <0x000bb>
at Java.Lang.IRunnableInvoker:n_Run <0x000c3>
at Android.Runtime.DynamicMethodNameCounter:20 <0x000af>
at Android.Runtime.DynamicMethodNameCounter:20 <0x000e3>
=================================================================
05-08 23:09:47.037 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.037 D/Mono (25933): Searching for 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): Probing 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.037 D/Mono (25933): Searching for 'shared_realm_resolve_query_reference'.
05-08 23:09:47.037 D/Mono (25933): Probing 'shared_realm_resolve_query_reference'.
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_query_reference'.
05-08 23:09:47.040 F/libc (25933): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x188 in tid 25933 (panyname.dosham), pid 25933 (panyname.dosham)
05-08 23:09:47.061 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.062 D/Mono (25933): Searching for 'query_destroy'.
05-08 23:09:47.062 D/Mono (25933): Probing 'query_destroy'.
05-08 23:09:47.062 D/Mono (25933): Found as 'query_destroy'.
05-08 23:09:47.259 I/panyname.dosha(25933): ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
Looks like it is a bug, removing the
using (var realm = Realm.GetInstance(DbConfig))
solved the issue, i.e.
var resultingEntries = await Task.Run(() =>
{
var allEntries = Realm.GetInstance(DbConfig).All<Entry>();
// Because realm doesn't support some of the LINQ operations on not stored fields (Content)
// the set of entries is converted to a IEnumerable.
IEnumerable<Entry> subset = allEntries;
// This is where the search gets actually done
subset = subset.Where(entry => entry.Content.ToLower().StartsWith(inputText));
// Extracts ids
var foundEntryIds = ExtractIdsFromEntries(subset);
// Select entries
var foundEntries = FindingManyMatches(allEntries, foundEntryIds.ToArray());
var foundEntriesCount = foundEntries.Count();
return ThreadSafeReference.Create(foundEntries);
});
var results = Realm.GetInstance(DbConfig).ResolveReference(resultingEntries);
return results;
Im trying to make a simple Listview, but i am getting an error and i dont know why! Can anyone tell me what I am doing wrong?
Code:
namespace ListViewApp
{
[Activity(Label = "ListViewApp", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
private List<string> nItem;
private ListView lview;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
lview = FindViewById<ListView>(Resource.Id.listView1);
SetContentView(Resource.Layout.Main);
nItem = new List<string>();
nItem.Add("Bob");
nItem.Add("XYZ");
nItem.Add("AAA");
nItem.Add("BBB");
ArrayAdapter adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, nItem);
lview.Adapter = adapter;
}
}
}
Error:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
An unhandled exception occured.
In mgmain JNI_OnLoad
D/dalvikvm( 3164): Late-enabling CheckJNI
D/dalvikvm( 3164): Trying to load lib /data/app-lib/ListViewApp.ListViewApp-1/libmonodroid.so 0xa503e468
D/dalvikvm( 3164): Added shared lib /data/app-lib/ListViewApp.ListViewApp-1/libmonodroid.so 0xa503e468
W/monodroid-debug( 3164): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8867,server=y,embedding=1
7 W/monodroid-debug( 3164): Accepted stdout connection: 42
D/Mono ( 3164): Image addref mscorlib[0xb8ef1fa8] -> mscorlib.dll[0xb8f0c290]: 1
D/Mono ( 3164): AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/mscorlib.dll.so" not found
D/Mono ( 3164): Assembly mscorlib[0xb8ef1fa8] added to domain RootDomain, ref_count=1
9 D/Mono ( 3164): Assembly Loader probing location: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll'.
D/Mono ( 3164): Image addref ListViewApp[0xb8f3fe38] -> /storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll[0xb8f3eff8]: 2
D/Mono ( 3164): Assembly ListViewApp[0xb8f3fe38] added to domain RootDomain, ref_count=1
3 D/Mono ( 3164): AOT module '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib//storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.so" not found
D/Mono ( 3164): Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll'.
D/Mono ( 3164): Config attempting to parse: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.config'.
D/Mono ( 3164): Config attempting to parse: '/Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/ListViewApp/ListViewApp.config'.
W/monodroid-gc( 3164): GREF GC Threshold: 46800
D/Mono ( 3164): Image addref Mono.Android[0xb8f40d78] -> Mono.Android.dll[0xb8f402a0]: 1
D/Mono ( 3164): Assembly Mono.Android[0xb8f40d78] added to domain RootDomain, ref_count=1
5 D/Mono ( 3164): AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/Mono.Android.dll.so" not found
D/Mono ( 3164): Assembly Ref addref Mono.Android[0xb8f40d78] -> mscorlib[0xb8ef1fa8]: 2
W/monodroid( 3164): Xamarin/Android Trial Mode Active
D/dalvikvm( 3164): GC_FOR_ALLOC freed 53K, 4% free 2752K/2864K, paused 188ms, total 195ms
D/dalvikvm( 3164): GC_CONCURRENT freed <1K, 4% free 3183K/3296K, paused 25ms+84ms, total 138ms
D/libEGL ( 3164): loaded /system/lib/egl/libEGL_genymotion.so
D/ ( 3164): HostConnection::get() New Host Connection established 0xb8f77590, tid 3164
D/libEGL ( 3164): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
D/libEGL ( 3164): loaded /system/lib/egl/libGLESv2_genymotion.so
W/EGL_genymotion( 3164): eglSurfaceAttrib not implemented
E/OpenGLRenderer( 3164): Getting MAX_TEXTURE_SIZE from GradienCache
E/OpenGLRenderer( 3164): MAX_TEXTURE_SIZE: 16384
E/OpenGLRenderer( 3164): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
E/OpenGLRenderer( 3164): MAX_TEXTURE_SIZE: 16384
D/OpenGLRenderer( 3164): Enabling debug mode 0
D/Mono ( 3164): Image addref System.Core[0xb8fb1c50] -> System.Core.dll[0xb8fb1040]: 1
D/Mono ( 3164): Assembly System.Core[0xb8fb1c50] added to domain RootDomain, ref_count=1
1 D/Mono ( 3164): AOT module 'System.Core.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/System.Core.dll.so" not found
D/Mono ( 3164): Assembly Ref addref Mono.Android[0xb8f40d78] -> System.Core[0xb8fb1c50]: 2
D/Mono ( 3164): Assembly Ref addref System.Core[0xb8fb1c50] -> mscorlib[0xb8ef1fa8]: 3
The program 'Mono' has exited with code 0 (0x0).
You should just first call:
SetContentView(Resource.Layout.Main);
and then
lview = FindViewById<ListView>(Resource.Id.listView1);
I'm playing an mp3 to provide background music to my iPad game, and I am playing the song using this code:
audioPlayer = AVAudioPlayer.FromUrl(NSUrl.FromFilename(fileName));
audioPlayer.FinishedPlaying += delegate { audioPlayer.Dispose(); audioPlayer=null; };
if (audioPlayer.PrepareToPlay())
audioPlayer.Play();
It works in fact, but when running I am getting a load of error messages in the console. Am I doing it wrong? Should I worry?
This is a dump of the errors I get:
2012-05-04 16:22:17.220 Music[42300:22b03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262):
Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.223 Music[42300:22b03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.256 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.258 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.260 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.261 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.263 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.264 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
These errors seem to be harmless (I have seen them a lot, but not noticed any actual problems).
In any case the errors will be fixed in a future version of MonoTouch.
I think I've determined that even though I'm loading assemblies in a MarshalByRefObject in a new AppDomain that the assemblies are also getting loaded into the parent domain.
Here's my Assembly structure (arrows indicate dependency):
MainAssembly -> CommonInterfaceAssembly <- ExtensionAssembly
In the parent AppDomain I'm doing this:
var loader = (ExtensionLoader)extDomain.CreateInstanceAndUnwrap (Assembly.GetExecutingAssembly().FullName, "ExtensionLoader");
loader.loadExtensions (this);
and the Loader class is:
class ExtensionLoader : MarshalByRefObject
{
public List<IExtension> loadExtensions (ExtensionMgr mgr)
{
// Delegate to Addins to return the list of extensions
AddinManager.Initialize ();
AddinManager.Registry.Update ();
AddinManager.GetExtensionObjects<IExtension> ();
var extensions = new List<IExtension> (AddinManager.GetExtensionObjects<IExtension> ());
foreach (var ext in extensions) {
ext.Initialize (mgr);
}
return extensions;
}
}
I don't know if it's relevant to the question, but I am using Mono.Addins to load the extensions in the new AppDomain so I've left that code in. From what I can tell though things work fine up to the point where I invoke the Initialize method on each of the extensions.
So I have ran this scenario with the ExtensionAssembly in the same directory as the main executable and in a separate 'extensions' directory. What's curious to me is that when I invoke ext.Initialize either the ExtensionAssembly gets loaded in the parent AppDomain (if it exists in the same directory), or I get the below stack trace if not. Any ideas why?
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x001f0] in /home/tim/tmp/mono-2.10.8/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:247
Exception rethrown at [1]:
---> System.IO.FileNotFoundException: Could not load file or assembly 'Extensions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Extensions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00047] in /home/tim/tmp/mono-2.10.8/mcs/class/corlib/System/AppDomain.cs:785
at System.AppDomain.Load (System.String assemblyString) [0x00000] in /home/tim/tmp/mono-2.10.8/mcs/class/corlib/System/AppDomain.cs:762