I am trying to run an executable program on Linux via Mono (as Wine will not comply), and I am given this output. I have searched and do not know what to do:
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v4.0.30319
cannot open file /root/Desktop/tool\GeoIP.dat
System.IO.DirectoryNotFoundException: Directory '/root/Desktop/tool\plugin\' not found.
at System.IO.Directory.ValidateDirectoryListing (System.String path, System.String searchPattern, System.Boolean& stop) <0x7f11f1ba74c0 + 0x0019c> in :0
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) <0x7f11f1ba7700 + 0x00066> in :0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) <0x7f11f1ba6d50 + 0x00018> in :0
at njRAT.Form1. (System.Object , System.EventArgs ) <0x4102ea90 + 0x006ea> in :0
at System.Windows.Forms.Form.OnLoad (System.EventArgs e) <0x410218f0 + 0x00071> in :0
at System.Windows.Forms.Form.OnLoadInternal (System.EventArgs e) <0x410216d0 + 0x0007f> in :0
System.NullReferenceException: Object reference not set to an instance of an object
at +. () <0x4103f510 + 0x001e6> in :0
at njRAT.Form1. (System.Object , System.Windows.Forms.FormClosingEventArgs ) <0x4103e250 + 0x000ab> in :0
at System.Windows.Forms.Form.OnFormClosing (System.Windows.Forms.FormClosingEventArgs e) <0x4103e1c0 + 0x00065> in :0
at System.Windows.Forms.Form.FireClosingEvents (CloseReason reason, Boolean cancel) <0x4103e070 + 0x0009d> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:FireClosingEvents (System.Windows.Forms.CloseReason,bool)
at System.Windows.Forms.Application.Exit (System.ComponentModel.CancelEventArgs e) <0x4103db20 + 0x001b7> in :0
at System.Windows.Forms.Application.Exit () <0x4103dae0 + 0x00027> in :0
at System.Windows.Forms.Application.OnThreadException (System.Exception t) <0x4103d630 + 0x00147> in :0
at System.Windows.Forms.Form.OnLoadInternal (System.EventArgs e) <0x410216d0 + 0x00097> in :0
at System.Windows.Forms.Form.OnCreateControl () <0x41020ef0 + 0x0004f> in :0
at System.Windows.Forms.Control.CreateControl () <0x412a3170 + 0x0011f> in :0
at System.Windows.Forms.Control.WmShowWindow (System.Windows.Forms.Message& m) <0x412ab7b0 + 0x00167> in :0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) <0x412aa4a0 + 0x002d7> in :0
at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) <0x4101b3b0 + 0x00013> in :0
at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) <0x4101b330 + 0x0005b> in :0
at System.Windows.Forms.Form.WndProc (System.Windows.Forms.Message& m) <0x4101af50 + 0x00257> in :0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) <0x412aa470 + 0x00024> in :0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) <0x412aa430 + 0x00036> in :0
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) <0x412a8d70 + 0x0031c> in :0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at +. () <0x4103f510 + 0x001e6> in :0
at njRAT.Form1. (System.Object , System.Windows.Forms.FormClosingEventArgs ) <0x4103e250 + 0x000ab> in :0
at System.Windows.Forms.Form.OnFormClosing (System.Windows.Forms.FormClosingEventArgs e) <0x4103e1c0 + 0x00065> in :0
at System.Windows.Forms.Form.FireClosingEvents (CloseReason reason, Boolean cancel) <0x4103e070 + 0x0009d> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:FireClosingEvents (System.Windows.Forms.CloseReason,bool)
at System.Windows.Forms.Application.Exit (System.ComponentModel.CancelEventArgs e) <0x4103db20 + 0x001b7> in :0
at System.Windows.Forms.Application.Exit () <0x4103dae0 + 0x00027> in :0
at System.Windows.Forms.Application.OnThreadException (System.Exception t) <0x4103d630 + 0x00147> in :0
at System.Windows.Forms.NativeWindow.OnThreadException (System.Exception e) <0x41040a70 + 0x00013> in :0
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) <0x412a8d70 + 0x00b51> in :0
at System.Windows.Forms.XplatUIX11.SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) <0x412a8650 + 0x0044f> in :0
at System.Windows.Forms.XplatUIX11.MapWindow (System.Windows.Forms.Hwnd hwnd, WindowType windows) <0x412ab2d0 + 0x001f3> in :0
at System.Windows.Forms.XplatUIX11.CreateWindow (System.Windows.Forms.CreateParams cp) <0x412a37e0 + 0x00c53> in :0
at System.Windows.Forms.XplatUI.CreateWindow (System.Windows.Forms.CreateParams cp) <0x412a37b0 + 0x0001f> in :0
at System.Windows.Forms.NativeWindow.CreateHandle (System.Windows.Forms.CreateParams cp) <0x412a3700 + 0x0003f> in :0
at System.Windows.Forms.Control.CreateHandle () <0x412a3420 + 0x00069> in :0
at System.Windows.Forms.Form.CreateHandle () <0x41019c40 + 0x00027> in :0
at System.Windows.Forms.Control.CreateControl () <0x412a3170 + 0x00087> in :0
at System.Windows.Forms.Control.SetVisibleCore (Boolean value) <0x412b4bb0 + 0x00083> in :0
at System.Windows.Forms.Form.SetVisibleCore (Boolean value) <0x41019420 + 0x00317> in :0
at System.Windows.Forms.Control.set_Visible (Boolean value) <0x412b4b30 + 0x00032> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool)
at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) <0x41017ec0 + 0x0033f> in :0
at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) <0x41017e10 + 0x00057> in :0
at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) <0x41017dc0 + 0x00033> in :0
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun () <0x4125e9d0 + 0x00077> in :0
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run (System.String[] commandLine) <0x4125e9b0 + 0x00010> in :0
at . (System.String[] ) <0x4125bd50 + 0x00043> in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at +. () <0x4103f510 + 0x001e6> in :0
at njRAT.Form1. (System.Object , System.Windows.Forms.FormClosingEventArgs ) <0x4103e250 + 0x000ab> in :0
at System.Windows.Forms.Form.OnFormClosing (System.Windows.Forms.FormClosingEventArgs e) <0x4103e1c0 + 0x00065> in :0
at System.Windows.Forms.Form.FireClosingEvents (CloseReason reason, Boolean cancel) <0x4103e070 + 0x0009d> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:FireClosingEvents (System.Windows.Forms.CloseReason,bool)
at System.Windows.Forms.Application.Exit (System.ComponentModel.CancelEventArgs e) <0x4103db20 + 0x001b7> in :0
at System.Windows.Forms.Application.Exit () <0x4103dae0 + 0x00027> in :0
at System.Windows.Forms.Application.OnThreadException (System.Exception t) <0x4103d630 + 0x00147> in :0
at System.Windows.Forms.NativeWindow.OnThreadException (System.Exception e) <0x41040a70 + 0x00013> in :0
at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) <0x412a8d70 + 0x00b51> in :0
at System.Windows.Forms.XplatUIX11.SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) <0x412a8650 + 0x0044f> in :0
at System.Windows.Forms.XplatUIX11.MapWindow (System.Windows.Forms.Hwnd hwnd, WindowType windows) <0x412ab2d0 + 0x001f3> in :0
at System.Windows.Forms.XplatUIX11.CreateWindow (System.Windows.Forms.CreateParams cp) <0x412a37e0 + 0x00c53> in :0
at System.Windows.Forms.XplatUI.CreateWindow (System.Windows.Forms.CreateParams cp) <0x412a37b0 + 0x0001f> in :0
at System.Windows.Forms.NativeWindow.CreateHandle (System.Windows.Forms.CreateParams cp) <0x412a3700 + 0x0003f> in :0
at System.Windows.Forms.Control.CreateHandle () <0x412a3420 + 0x00069> in :0
at System.Windows.Forms.Form.CreateHandle () <0x41019c40 + 0x00027> in :0
at System.Windows.Forms.Control.CreateControl () <0x412a3170 + 0x00087> in :0
at System.Windows.Forms.Control.SetVisibleCore (Boolean value) <0x412b4bb0 + 0x00083> in :0
at System.Windows.Forms.Form.SetVisibleCore (Boolean value) <0x41019420 + 0x00317> in :0
at System.Windows.Forms.Control.set_Visible (Boolean value) <0x412b4b30 + 0x00032> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:set_Visible (bool)
at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) <0x41017ec0 + 0x0033f> in :0
at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) <0x41017e10 + 0x00057> in :0
at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) <0x41017dc0 + 0x00033> in :0
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun () <0x4125e9d0 + 0x00077> in :0
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run (System.String[] commandLine) <0x4125e9b0 + 0x00010> in :0
at . (System.String[] ) <0x4125bd50 + 0x00043> in :0
Nothing to do with the warning, but an exception showed later. Your form tries to load an GeoIP file from disk but it uses a Windows only file path which definitely fails on Linux. Learn the file system differences and revise your code.
Related
I have a crash in SLL_Next in a setter of an attribute of type vector<pair<int,enum>>
void setA(const vector<pair<int,enum>>& A){_A = A;} // A.size() = 1
class B {
vector<pair<int,enum>> _A {};
public:
void setA(const vector<pair<int,enum>>& A){_A = A;}
};
int main(){
.
.
.
vector<pair<int,enum>> A;
.
.
.
A.push_back(element);
.
.
.
setA(A);// get segfault in SLL_Next
.
.
.
}
Back trace :
Thread 1 "a" received signal SIGSEGV, Segmentation fault.
tcmalloc::SLL_TryPop (rv=<synthetic pointer>, list=0x790f060) at src/linked_list.h:69
69 void *next = SLL_Next(*list);
(gdb) bt
#0 tcmalloc::SLL_TryPop (rv=<synthetic pointer>, list=0x790f060) at src/linked_list.h:69
#1 tcmalloc::ThreadCache::FreeList::TryPop (rv=<synthetic pointer>, this=0x790f060) at src/thread_cache.h:220
#2 tcmalloc::ThreadCache::Allocate (oom_handler=0x7ffff78c5300 <tcmalloc::cpp_throw_oom(unsigned long)>, cl=1, size=8, this=<optimized out>) at src/thread_cache.h:379
#3 malloc_fast_path<tcmalloc::cpp_throw_oom> (size=8) at src/tcmalloc.cc:1874
#4 tc_new (size=8) at src/tcmalloc.cc:1995
#5 0x0000000000506e50 in __gnu_cxx::new_allocator<std::pair<int, enum> >::allocate (this=0x114aedc8, __n=1) at /u/tools/gnu/gcc/os3fp/gcc-6.2.0/include/c++/6.2.0/ext/new_allocator.h:104
#6 0x000000000050334b in std::allocator_traits<std::allocator<std::pair<int, enum> > >::allocate (__a=..., __n=1) at /u/tools/gnu/gcc/os3fp/gcc-6.2.0/include/c++/6.2.0/bits/alloc_traits.h:416
#7 0x00000000004fd3b2 in std::_Vector_base<std::pair<int, enum>, std::allocator<std::pair<int, enum> > >::_M_allocate (this=0x114aedc8, __n=1) at /u/tools/gnu/gcc/os3fp/gcc-6.2.0/include/c++/6.2.0/bits/stl_vector.h:170
#8 0x00000000004f9a92 in std::vector<std::pair<int, enum>, std::allocator<std::pair<int, enum> > >::_M_allocate_and_copy<__gnu_cxx::__normal_iterator<std::pair<int, enum> const*, std::vector<std::pair<int, enum>, std::allocator<std::pair<int, enum> > > > > (this=0x114aedc8, __n=1, __first=..., __last=...)
at /u/tools/gnu/gcc/os3fp/gcc-6.2.0/include/c++/6.2.0/bits/stl_vector.h:1222
#9 0x00000000004f70fc in std::vector<std::pair<int, enum>, std::allocator<std::pair<int, enum> > >::operator= (this=0x114aedc8, __x=...) at /u/tools/gnu/gcc/os3fp/gcc-6.2.0/include/c++/6.2.0/bits/vector.tcc:195
#10 0x00000000004f616e in B::setA (this=0x114aed20, A=...) at ~/WORK/B.h:110
I tried to do the following scenarios:
Scenario(1):
Clear the vector A just before doing setA(A)
Replace _A = A by _A.reserve(1) But I got the same segfault.
Code source became:
class B {
vector<pair<int,enum>> _A {};
public:
void setA(const vector<pair<int,enum>>& A){_A.reserve(1);}
};
int main(){
.
.
.
vector<pair<int,enum>> A;
.
.
.
A.clear();
setA(A);// get the same segfault in SLL_Next
.
.
.
}
Scenario(2)
Replace void setA(const vector<pair<int,enum>>& A){_A = A} by void setA(const vector<pair<int,enum>>& A){_A.reserve(2)}, the program pass this segfault and crashes in other different vector with the same segfault.
Scenario(3)
If I use a build without tcmalloc, the program will pass successfully.
Scenario(4)
If I change the type of _A from vector to set, the program passes this segfault and crashes with the same segfault in other vectors.
Does anyone have ever faced this kind of issue with using tcmalloc can please advise me on how to solve it?
I'm trying to implement some fairly basic/standard Xamarin.iOS code around sharing credentials between my iOS app and associated website.
public void TryGetSharedCredential(Action<Tuple<string, string>> callback)
{
try
{
Security.SecSharedCredential.RequestSharedWebCredential("www.jg.com", "me#jg.com", (accounts, err) =>
{
if (accounts != null && accounts.Any())
{
var email = accounts[0];
var password = accounts[1];
callback(new Tuple<string, string>(email, password));
}
});
}
catch (Exception ex)
{
//log exception
}
callback(null);
}
However, RequestSharedWebCredential crashes with the following log (and never enters the NSAction).
2017-10-02 16:33:30.083 JGMobileIOS[65076:4639965] -[__NSCFDictionary UTF8String]: unrecognized selector sent to instance 0x608000282f40
2017-10-02 16:33:30.091 JGMobileIOS[65076:4639965] Xamarin.iOS: Received unhandled ObjectiveC exception: NSInvalidArgumentException -[__NSCFDictionary UTF8String]: unrecognized selector sent to instance 0x608000282f40
2017-10-02 16:33:34.363 JGMobileIOS[65076:4640005] critical: Stacktrace:
2017-10-02 16:33:34.364 JGMobileIOS[65076:4640005] critical:
Native stacktrace:
2017-10-02 16:33:34.365 JGMobileIOS[65076:4640005] critical: 0 JGMobileIOS 0x0000000104938004 mono_handle_native_crash + 244
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 1 JGMobileIOS 0x0000000104945970 mono_sigsegv_signal_handler + 288
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 2 libsystem_platform.dylib 0x000000011151db3a _sigtramp + 26
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 3 ??? 0x0000000000000000 0x0 + 0
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 4 JGMobileIOS 0x00000001049988bc mono_debug_symfile_lookup_method + 44
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 5 JGMobileIOS 0x00000001049fc87d lookup_method_func + 61
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 6 JGMobileIOS 0x0000000104ad75bd monoeg_g_hash_table_foreach + 77
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 7 JGMobileIOS 0x00000001049fc2f9 mono_debug_lookup_method_async_debug_info + 105
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 8 JGMobileIOS 0x000000010489bfbb ss_start + 331
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 9 JGMobileIOS 0x0000000104897b16 debugger_thread + 27910
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 10 JGMobileIOS 0x0000000104a4b283 start_wrapper + 675
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 11 libsystem_pthread.dylib 0x000000011152f93b _pthread_body + 180
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical: 12 libsystem_pthread.dylib 0x000000011152f887 _pthread_body + 0
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical: 13 libsystem_pthread.dylib 0x000000011152f08d thread_start + 13
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical:
=================================================================
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.
=================================================================
I have tried:
On simulator and device
Without any linking ("Don't Link")
Also tried the overloads that don't specify domain and account. According to the docs, if you pass a null domain, the domains specified in
Entitlements.plist are checked. And if you specify a null account,
then all stored accounts for that domain are supposed to be returned.
Same crash.
I have checked entitlements.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:www.jg.com</string>
<string>webcredentials:www.jg.com</string>
</array>
</dict>
</plist>
I have the correct json at: www.jg.com/.well-known/apple-app-site-association (on https)
{
"applinks": {
//applink stuff
},
"webcredentials": {
"apps": [
//full teamid + appid
]
}
}
I believe something is going wrong underneath the following Xamarin -> iOS api method mapping:
public static void AddSharedWebCredential (string domainName, string account, string password, Action<NSError> handler);
public static string CreateSharedWebCredentialPassword ();
public static void RequestSharedWebCredential (string domainName, string account, Action<string[], NSError> handler);
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern void SecAddSharedWebCredential (IntPtr fqdn, IntPtr account, IntPtr password, IntPtr completionHandler);
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern IntPtr SecCreateSharedWebCredentialPassword ();
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern void SecRequestSharedWebCredential (IntPtr fqdn, IntPtr account, IntPtr completionHandler);
How can I get more details on what is going wrong? Am I missing anything and/or what else can I try?
After working with a Xamarin Support Engineer, turns out this was a bug in Xamarin.iOS, and will be fixed in a future release:
https://bugzilla.xamarin.com/show_bug.cgi?id=60423
Fix committed here: https://github.com/xamarin/xamarin-macios/commit/03b9d1759e0bafe5d94d319e5a58f798a3ce575b
I have the following signature from c++
IDTECHREADER_EXPORTS void ReadTwoBlocks(char *pathConfig,
char *datablock1, char *datablock2, int timeout, bool &ret )
I was able to Marshal this correctly on the Full .NetFrameWork and it works as below
[DllImport("IDTechReader.dll", EntryPoint = "ReadTwoBlocks" )]
private static extern void _ReadTwoBlocks(
[In][MarshalAs(UnmanagedType.LPStr)] string pathConfig,
[Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder datablock1,
[Out] [MarshalAs(UnmanagedType.LPStr)] StringBuilder datablock2,
int TimeOut,
ref bool result);
However using the same Marshaling as above doesn't work on the NetcompactFramework(Windows CE) it gives an error "NotSupported Exception"
How do we correctly Marshal the above C++ method signature so that it will work correctly on the .NET CompactFramework(windows CE)
any ideas are apperciated...thanks.
The marshaler is probably choking on the MarshalAs(UnmanagedType.LPStr). You're either going to have to change the signature to a fixed size byte[] and do the string conversion in managed code using Encoding.ASCII.GetString(), or you could use an IntPtr type and allocate the memory using Marshal.AllocHGlobal/FreeHGlobal and deal with the string conversion in your code.
I think this might work..
private const int MAX_STRING = 256;
[DllImport("IDTechReader.dll", EntryPoint = "ReadTwoBlocks")]
private static extern void _ReadTwoBlocks(
byte[] pathConfig,
[Out] byte[] datablock1,
[Out] byte[] datablock2,
int TimeOut,
ref bool result);
public void ReadTwoBlocks(string pathConfig,
StringBuilder datablock1,
StringBuilder datablock2,
int TimeOut,
ref bool result)
{
var pathConfigBuff = new byte[MAX_STRING];
var datablock1Buff = new byte[MAX_STRING];
var datablock2Buff = new byte[MAX_STRING];
// Convert unicode string to null terminated single byte charater string
Array.Copy(Encoding.ASCII.GetBytes(pathConfig), pathConfigBuff, pathConfig.Length);
// Call your native method
_ReadTwoBlocks(pathConfigBuff, datablock1Buff, datablock2Buff, TimeOut, ref result);
// If success, copy the datablocks to the StringBuffers
if (result)
{
datablock1.Append(Encoding.ASCII.GetString(datablock1Buff, 0, MAX_STRING).Replace('\0', ' ').Trim());
datablock2.Append(Encoding.ASCII.GetString(datablock2Buff, 0, MAX_STRING).Replace('\0', ' ').Trim());
}
}
It would be something like this:
[DllImport("IDTechReader.dll")]
private static extern void ReadTwoBlocks(IntPtr pathConfig,
IntPtr datablock1, IntPtr datablock2, int timeout, ref bool ret);
and when you use it like this:
string pathConfig = "..\program.ini";
IntPtr ptrPathConfig = IntPtr.Zero;
ptrPathConfig = Marshal.StringToHGlobalAnsi(pathConfig);
IntPtr ptrDatablock1 = IntPtr.Zero;
IntPtr ptrDatablock2 = IntPtr.Zero;
int timeout = 300;
bool ret = false;
ReadTwoBlocks(ptrPathConfig, ptrDatablock1, ptrDatablock2, timeout, ref ret);
string db1 = Marshal.PtrToStringAnsi(ptrDatablock1);
string db2 = Marshal.PtrToStringAnsi(ptrDatablock2);
I have a problem using multiple UIBarButtonItems within a UIToolbar on one side of a UINavigationController. I‘ve used one of the many examples on how to put multiple buttons in the navigation bar (using a toolbar), and while I got it displaying correctly now, I always get an unkown Objective-C exception thrown when a button is pressed.
This is the full test UIViewController I use for adding multiple buttons:
using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace TestProject
{
public class Test : UIViewController
{
public override void ViewDidLoad ()
{
base.ViewDidLoad();
UIBarButtonItem btn1 = new UIBarButtonItem( "foo", UIBarButtonItemStyle.Bordered, delegate(object sender, EventArgs e) {
Console.WriteLine( "asdf" );
} );
UIBarButtonItem btn2 = new UIBarButtonItem();
btn2.Style = UIBarButtonItemStyle.Bordered;
btn2.Title = "bar";
btn2.Clicked += delegate(object sender, EventArgs e) {
Console.WriteLine( "fdsa" );
};
UIToolbar tb = new UIToolbar( new RectangleF( 0, 0, 150, 44.0f ) );
tb.SetItems( new UIBarButtonItem[] { btn1, btn2 }, false );
NavigationItem.RightBarButtonItem = new UIBarButtonItem( tb );
}
}
}
I put that controller within a UINavigationController and display its view as the only window content. Everything works fine, until I click one of the buttons:
Error connecting stdout and stderr (127.0.0.1:10001)
Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26
at TestProject.Application.Main (string[]) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 TestProject 0x000d0de8 mono_handle_native_sigsegv + 343
1 TestProject 0x0000f74c mono_sigsegv_signal_handler + 322
2 libSystem.B.dylib 0x906fc45b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 UIKit 0x01ee6cc3 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
5 UIKit 0x01cd44fd -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x01d64799 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x01d66c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x01d657d8 -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x01cf8ded -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x01cd9c37 -[UIApplication sendEvent:] + 447
11 UIKit 0x01cdef2e _UIApplicationHandleEvent + 7576
12 GraphicsServices 0x0404f992 PurpleEventCallback + 1550
13 CoreFoundation 0x00ea2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x00e02cf7 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x00dfff83 __CFRunLoopRun + 979
16 CoreFoundation 0x00dff840 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x00dff761 CFRunLoopRunInMode + 97
18 GraphicsServices 0x0404e1c4 GSEventRunModal + 217
19 GraphicsServices 0x0404e289 GSEventRun + 115
20 UIKit 0x01ce2c93 UIApplicationMain + 1160
21 ??? 0x077efe64 0x0 + 125763172
22 ??? 0x077ef1e2 0x0 + 125759970
23 ??? 0x077ef0be 0x0 + 125759678
24 ??? 0x077ef145 0x0 + 125759813
25 TestProject 0x0000f507 mono_jit_runtime_invoke + 1332
26 TestProject 0x001ed259 mono_runtime_invoke + 137
27 TestProject 0x001ef940 mono_runtime_exec_main + 669
28 TestProject 0x001eed2a mono_runtime_run_main + 843
29 TestProject 0x000a3093 mono_jit_exec + 200
30 TestProject 0x002a163d main + 4060
31 TestProject 0x00002819 _start + 208
32 TestProject 0x00002748 start + 40
Debug info from gdb:
dyld: could not load inserted library: /Users/Apple/Library/Application Support/iPhone Simulator/4.3/Applications/86C48AC1-821F-49DD-B344-58471F02D31B/TestProject.app/monotouch-fixes.dylib
=================================================================
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.
=================================================================
Does anyone know what‘s causing this, and more importantly how to avoid it? When setting just a single button as the RightBarButtonItem it works without any problems.
edit
Above error seems to randomly cycle with this one:
Error connecting stdout and stderr (127.0.0.1:10001)
2011-08-25 13:30:05.409 TestProject[1235:a0b] -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980
Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26
at TestProject.Application.Main (System.String[] args) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26
at TestProject.Application.Main (System.String[] args) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16
Declare the buttons as class variables. The GC collects them so your event handlers are causing memory leaks.
I'm using ICSharpCode.SharpZipLib for unzip a file that contain file, folders and subfolders inside, but i'm getting an error that I didn't find here or in any other forum.
Code:
public static void UnZipFiles(string zipPathAndFile, string outputFolder, string password, bool deleteZipFile)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(zipPathAndFile));
if (password != null && password != String.Empty)
s.Password = password;
ZipEntry theEntry;
string tmpEntry = String.Empty;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = outputFolder;
string fileName = Path.GetFileName(theEntry.Name);
// create directory
if (directoryName != "")
{
Directory.CreateDirectory(directoryName);
}
if (fileName != String.Empty)
{
if (theEntry.Name.IndexOf(".ini") < 0)
{
string fullPath = directoryName + "\\" + theEntry.Name;
fullPath = fullPath.Replace("\\ ", "\\");
string fullDirPath = Path.GetDirectoryName(fullPath);
if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
FileStream streamWriter = File.Create(fullPath);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
}
s.Close();
if (deleteZipFile)
{
File.Delete(zipPathAndFile);
}
}
Error got:
Unhandled Exception: ICSharpCode.SharpZipLib.SharpZipBaseException: Unknown block type 6
at ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Decode () [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Inflate (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.BodyRead (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.InitialRead (System.Byte[] destination, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.CloseEntry () [0x00000] in <filename unknown>:0Error connecting stdout and stderr (127.0.0.1:10001)
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry () [0x00000] in <filename unknown>:0
at FolderNavigation.ZipController.UnZipFiles (System.String zipPathAndFile, System.String outputFolder, System.String password, Boolean deleteZipFile) [0x00119] in /Users/claudio/Projects/FolderNavigation/FolderNavigation/ZipController.cs:15
at FolderNavigation.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x0005e] in /Users/claudio/Projects/FolderNavigation/FolderNavigation/Main.cs:43
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31
at FolderNavigation.Application.Main (System.String[] args) [0x00000] in /Users/claudio/Projects/FolderNavigation/FolderNavigation/Main.cs:14
Any idea?
Regards,
Claudio
Have you tried to unzip the file via the code on .NET in windows for example? Maybe the file is zipped by some technique SharpZipLib does not support?
I'm judging by the fact that error happens in 'ICSharpCode.SharpZipLib.Zip.Compression.Inflater.Decode' method, which if you check the source code for the SharpZipLib just decodes the array of deflated bytes.