I want to program an app that can Read Data from a FTDI device that is connected via the USB port on an android device. I tried working with xamarin in visual studio 22 in c#.
So I am able to add the library (FTDI D2XX) into my project and also to use all the functions, but as soon as i want to emulate it, i get this error:
System.NotSupportedException Message = Could not activate JNI Handle 0x7fffa3677900 (key_handle 0x8a201d9) of Java type 'crc6496017b555982539e/MainActivity' as managed type '(Myproject).MainActivity'
error
Its not a problem with the emulator or the program because when i remove all commands from the FTDI library only, it works fine.
Seems like a compatibility problem to me...
On startup of the app i see a warning:
#(Content) build action is not supported (Path to my Project)\ftd2xx.dll
Is there a way around? I choose VS and NET because i dont want to program the app in java. If anyone knows a solution please help! An alternative to this would be welcome as well
Tried to update the NET library, tried using the source code of the library, tried using a NuGet reference - all leading to the same error
Related
Android projects run natively on Java, and NDK projects basically work by having a special Activity that launches your native code. For example, SDL has an Activity that initializes SDL, sets up a display window, and then launches your project.
I'm trying to see how Xamarin does it. Technically, CLR code is managed code rather than native, but the CLR itself is native code and the whole thing would look like an NDK project to the Android runtime. I've been looking around, but I can't find where the Android project launcher is in Xamarin, and Googling it turns up nothing useful.
What is the mechanism by which Xamarin launches your CLR project on an Android device?
What is the mechanism by which Xamarin launches your CLR project on an Android device?
You can refer to Application Startup.
When an app is launched in Android device, Android will load it by specified #android:name in manifest, then usually all types will be instantiated by invoking ContentProvider.attachinfo() method, Xamarin.Android then here adding a mono.MonoRuntimeProvider ContentProvider during the build process. The mono.MonoRuntimeProvider.attachInfo() method will then replace the native ContentProvider.attachinfo() method to load Mono runtime into the process.
This is how I understand that document, please advise me if there is any mistake, many thanks.
As the title says I am wanting to share a Sqlite database between an Android app written in Java and one written in C# using Xamarin. I can successfully share a database between two Java apps (With the help of this question) but when I try the same thing in Xamarin I am getting the following error:
Android.Database.Sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
I think I have two problems.
I am not correctly setting the Shared UserId. Currently I am placing the following attribute above my main activity.
[Register("my.user.id")]
I tried using the android:sharedUserId="my.user.id" in the Manifest file but that was throwing errors and wouldn't deploy to my device.
I don't know how the whole signing of the app works. So maybe my device sees the two apps as coming from a different publisher for each device and is not allowing the two to share context.
EDIT :
Just wanted to add how I signed both applications with the same certificate for future refrence.
The Android cert is noramlly "C:\Users\userName\.android\debug.keystore" and the Xamarin cert is noramlly in "C:\Users\userName\AppData\Local\Xamarin\Mono for Android\debug.keystore". I built the Xamarin app first so I copied the debug.keystore file from the xamarin folder to the android one. (I'm sure it would work the other way around but haven't tested it)
Xamarin.Android does not support SharedUserId via an ApplicationAttribute. (I guess no one every filed an issue about it)
Ref: Android.App.ApplicationAttribute
Add your shared user id via the manifest and it will work fine:
Example:
<application android:allowBackup="true" android:sharedUserId="com.sushihangover" android:icon="#mipmap/icon" android:label="#string/app_name"></application>
Note: Make sure that you manually uninstall both apps, add the sharedUserId, rebuild and reinstall both apps.
Note: Make sure that you are using the same signing certificate for both your Java and Xamarin apps.
Every time I try to add the Interactive Brokers API control on my computer it gives me an error that sais....
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1)
I have been looking for an answer and trying different things for a week now and I can not seem to figure it out. I tried it on my laptop and it worked. I thought it was my windows or my visual studio so i re-installed everything on my PC. I'm not running a Windows 7 Professional x64 with Visual Studio 2013 with the newest update. At this point I have no idea what to try to make it work. Does anybody know what is this error.
Sorry-very late for an answer to this but in case someone else comes across it. There are a number of reasons why Visual Studio might not be able to add the control to your application. For 64-bit windows, one of the main issues is that the ActiveX control (tws.ocx) is not registered properly when the API is installed. I have a web page dedicated to installing IB API on Windows and I list out many of the issues that can happen when working with the ActiveX control on 64-bit windows: http://holowczak.com/ib-install/
I just posted a very simple tutorial on my website that starts at the very beginning and walks you through getting the API to work with interactive brokers using Visual Studio and C# : Get Real-Time Stock data from Interactive Brokers API
If that doesn't help I would consider:
Turn off Windows Firewall and give it a try.
Ensure you have Traders Workstation setup to allow incomming connections for ActiveX/.NET.
Ensure Traders Workstation works on your machine. Try downloading it from IB and launching it. If it works, then the problem is on the .NET or connection from .NET to TWS which is Java.
Also when you say "Interactive Brokers Control" do you mean the API package that you can download? If so to build it into your program all you need is the .DLL file as shown in the tutorial link I posted above.
I am new to using Xamarin and have always used Visual Studio, however I now require to develop a desktop application which will run on both Mac and Windows, OR at least a package which will let me package for both.
I have created a GTK 2.0 Project, connected to a MySQL database etc and all is fine, however I can only see options to create a .exe and no .dmg file for OS X but the debugger lets me run it on my Mac.
Does anyone have any ideas or pointers?
We use Xamarin.Mac to enable us to develop a Windows and Mac client using c#.
We chose to re-build the core code in Xamarin Studio and use interfaces to abstract the OS dependent code.
We share 90% of our code in the Xamarin.Mac/VS solutions.
Do let me know if I'm helping... if so I can provide more detail if need be.
Check the following link on how to create an .app bundle with Xamarin:
How to set Xamarin MonoMac project so its build outputs .app package instead of .exe?
An app bundle is basically a special kind of folder structure that contains all app data, including e.g. graphical resources, configuration files, localisations, etc...
A .dmg file is used for distribution and can be created using other tools like Apple's own Disk Utility, once you've created the app.
I am writing a portable service/daemon using .NET 3.5, my windows service is running, but I was wondering about the mono port...
Mono-service is what I am looking for if I understand correctly. How exactly does this work though? I assume I need mono compatible code throughout my service, right? For example, I am using SQLite. Is it correct that in order to use this with mono I should refactor my code to use mono namespaces etc, such as Mono.Data.SQLite? May I still use Settings.settings?
Also, I've read that daemons don't implement onStart/Stop methods, so do I need to change my code to run under mono/linux? i.e. is it ok to have these methods in my code, and ok to run ServiceBase.Run()? Does Mono-service accommodate these?
You should create your programs from the beginning for use with Windows and Linux.
You need Visual Studio with Mono Tools or the free MonoDevelop-IDE to create a Mono-Application. MonoDevelop can import your Visual Studio Project. This IDE helps you to get the right namespaces.
Use Mono-Service to run your Assembly as daemon. Linux Daemons are using Signals to communicate with the System. Please read the documentation.
We already had a similar question, so please read this to see, how to process Unix-Signals.