WP8 - Re-using a native DLL through Windows Runtime Component - windows-phone-8

I have a native dll that I'd like to use in a WP8 project that I'm working on. I've done some research and have created a C++ Windows Runtime Component (WRC) to wrap the native DLL. The WRC project uses a .lib file, and my WP8 application calls the WRC project.
My solution compiles all fine, but when my application makes a call to a method in the native DLL, I get a The specified module could not be found. (Exception from HRESULT: 0x8007007E) exception.
From reading around it seems like the dll is not being loaded. I've copied all relevant dlls to the output dir of where the .exe file is and also in various places but the error keeps showing up.
If anyone could point me in the right direction I'd be very grateful. Also if more info is required I'll post that up also.

The DLL must be included in your XAP package. Something you can see being taken care of in the Output window when you build your app, it starts with the "Begin Xap packaging" messages and then lists all the files that get added. The runtime error says it is not being included.
There is remarkably little guidance on how to ensure that a file gets included in a phone package when MSBuild cannot figure out the dependencies by itself. It certainly won't for your DLL, no way the build system can tell if it isn't a project in your solution. Seems you're operating a bit on the bleeding edge in this case :)
But this works well when I try it, going by the MSBuild output and not by actually testing it: Project + Add Existing Item. Navigate to your DLL and select it. Select it in the Solution Explorer window and look in the Properties window. Ensure that "Build Action" = Content, Copy to Output Directory = "Copy if newer". Rebuild, you'll now see the file getting added to the XAP. Which should solve this particular error. There might be others :)

Windows Desktop or Windows Store native DLLs are not binary compatible with Windows Phone, even if they are built for the same CPU architecture.
Therefore you will need to recompile your native DLL for the Windows Phone toolset.
About Windows Runtime Components:
On Windows Phone a Windows Runtime Component is itself a native DLL (.NET is not supported on the phone). The binaries of Windows Runtime Components cannot be shared between Windows Store apps and Windows Phone apps.

Related

How to use third party dll in windows phone 8.1 application with windows runtime component?

I have created the windows phone 8.1 application in which I want to use third party dll file. That's why I have created windows runtime component for the windows phone project. I have given reference of the runtime component to the windows phone 8.1 application project.
In windows runtime component, I have set the additional Include directory path. Moreover, I have also set the Linker -> Input ->additional dependencies as lib file listing. I have drag drop all dll files in my c# windows phone application main project folder and set build action as content and copy output directory as copy always.
However, I got the following error.
An exception of type 'System.IO.FileNotFoundException' occurred in App1.WindowsPhone.exe but was not handled in user code
I have checkout the following question. But did not resolve it.
How to use a C++ dll in Windows Phone 8.1 XAML App within C++ Runtime Component
I found the answer. All the dependencies has been set properly. There was an issue in the dll file which architecture does not match with the current platform.
After created the build for proper architecture, it works.

Compiling sqlite-winrt for using SQL in WinRT/WP app with SQLite

I'm trying to use the sqlite-winrt library at https://sqlwinrt.codeplex.com (cf. http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/05/30/sqlite-winrt-wrapper-for-windows-phone.aspx) because I need to access an SQLite database via SQL commands in a WinRT 8.1 and a WP8 app and this library seems the only available option.
Anyway, there is no binary release and if I try compiling the source I get several link errors for unresolved externals against the SQLite DLL. I posted an issue at codeplex but got no reply yet, so I was wondering if anyone had already managed to successfully compile this lib and how (or if you know of any viable alternative for RT8.1 and WP8). Here is what I did:
downloaded the latest source from the site.
downloaded and installed 2 VSIX from http://www.sqlite.org/download.html: sqlite-winrt81-3080002.vsix for RT 8.1 and sqlite-wp80-winrt-3080100.vsix for WP.
executed the powershell scripts in each subfolder of the source code solution, which are required to update the projects with newer releases of the SQLite for WinRT extension. The current versions of the scripts refer to SQLite for WinRT 8.1 (prerelease) which is the same I downloaded above.
opened the VS2013 solution and removed the RT project (I just need RT8.1 and WP, this was for WinRT 8.0).
5) built the solution, which failed with link errors.
If I see the RT8.1 project properties, I can confirm the reference to SQLite is under C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\SQLite.WinRT81\3.8.0.2.
Did anyone manage to use this lib? Thanks!
I also once had that problem. I fix it by editing the project file manually. At that time, the powershell script updating the wrong path. That's why I always failed when compiling my project. After I edit the project file using external text editor (I use sublime text), the projects are linked correctly.
You can try DatabasesCx. It is another SQLite Wrapper using Windows Runtime Component technology. It is freeware distributed as precompiled binary. You can find the details at http://www.almanacsoft.com/databasescx

AIR file too big, breaks during installation

A client is having me convert an HTML5 video web application that I've already built into an AIR app.
The end users are going to need this to work with no internet access, so I MUST include a LOT of video files with the installer. This works fine on my machine, but my client can't install it because the .air file is too large and they don't have enough RAM. We'll need this installed on a number of laptops that aren't super powerful.
My SDK is up to date and we're using AIR 3.1.
Has anyone else run into a similar situation? Is there any workaround? For instance could I either include both the installer and the .air in a zipped folder, then have the installer move the video files to the appropriate location, or use AS to have the installer download the files (they will have internet access when installing).
I'd recommend you not to include heavy video files into your application. Downloading assets from web is a descent idea, I use same technique for several museum touchscreen apps.
So here's workflow: on startup app tries to connect to "assets server" and request list of files to download. It can be list of all the files, or list of files that have been updated/added since timestamp that you pass with your request. Then you download them to File.applicationStorageDirectory. Not to have mess in that directory I put all of them to "cache" subdirectory.
In case there's no internet connection for some reason when you install that app, you can have all that "cache" folder on your memory-stick/externalHD so you can manually perform that downloading process.
If you use Greensock's LoaderMax: I've written a simple URLStreamLoader that extends LoaderItem, handy for downloading files. Can share that.
The problem is quite obvious: the Adobe AIR provided installer for deploying your application is lacking.
However, Adobe recently released a new feature for deploying Adobe AIR apps: "runtime captive bundle" (Windows or OSX).
Which means 2 important things:
You receive an .exe which no longer requires an user to have Adobe AIR runtime installed (and no more incompatibilities when targeting multiple Adobe AIR runtimes).
You are no longer provided with an installer, and you have to find your own (which solves your problem halfway).
Target bundle when "compiling", and then just use a better installer (Windows or OSX) - think you are just deploying a normal application (worked for me:) ). There are too many installers arround to mention.
Your installer of choice + bundle compiling, together solve your offline installation requirement and the memory exhausting issue.
Packaging a captive runtime bundle for desktop computers

JavaFx 2 applicaton does not run when i run it through HTML page

I have downloaded the javafx 2 samples and want to run in from its HMTL. For example there is one javafx application called BrickBreaker. For the specific sample the following files exist : BrickBreaker.jar, BrickBreaker.jnlp and BrickBreaker.html
When double clicking on jar or jnlp the application runs as expected but when i click on the html the application does not run. Instead i get the message "View the conectes of the page. Please install javaFX"
Why is that happening ? ( i have the javafx installed as the application runs when choosing the jar and jnlp files). My guess is that the html should be called from within the context of a webserver meaning that i should deploy my application first to a server and call the url from my explorer. For example if using glassfish i should call the url http://localhost:8080/Brickbraker
The problem is that i don't know how to deploy the javafx application in the server.
i tried to copy paste all the above three files in the autodeploy folder but it didnt worked...
Could you please help me?
Thanks in advance
EDIT: some more info - I have installed JDK 7 and JavaFX SDK 2.0.2
No, JavaFX is client technology, you don't need Glassfish to run it. JavaFX should run in browser the same way as Java plugins do.
If you can't run an application directly from html file it means your browser doesn't recognize you have runtime installed.
There can be next reasons for that:
JavaFX runtime is actually not installed (check in Windows Control Panel)
pure java plugin is not installed (you can check on java.com)
javafx runtime is 32bit and you are using 64bit browser (or vice versa)
you are using not supported browser (e.g. Safari)
you are using not supported system (at this moment, January 2012, only Windows supports runtime)

Flash Builder Mac Breakpoints generate NullPointerExceptions

I have a complex, pre-existing Actionscript project to work with at my current employer. The project was originally created with FlashDevelop, which is not an option for me as a Mac user. I can successfully build the project and deploy it to others. It runs as expected.
The problem is with the debugging. I cannot make it work. I believe users of Flash Builder on Windows machines have successfully debugged this project on their machine. I can build and debug projects I make myself. It's THIS particular project, or something about how it is constructed, that is preventing debugging from occurring.
Symptoms:
Starting the program via the Debug button runs the program, but the presence of a breakpoint causes the program to freeze the browser where it is running
Removing the breakpoint or stopping the debugger allows the browser to unfreeze and continue normally
At no point does the breakpoint actually get reached and break into the debugger
Attempting to place a breakpoint during execution results in an internal error: java.lang.NullPointerException
Example log message from within .metadata/.log
java.lang.NullPointerException
!STACK 0
!MESSAGE Error processing debugger commands
!ENTRY com.adobe.flexbuilder.project 4 43 2011-08-24 13:35:07.404
at java.lang.Thread.run(Thread.java:680)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.run(FlexDebugTarget.java:793)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.eventLoop(FlexDebugTarget.java:732)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread$1.run(FlexDebugTarget.java:752)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.access$7(FlexDebugTarget.java:642)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.advanceStateMachine(FlexDebugTarget.java:668)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget$FdbThread.installDeferredBreakpoints(FlexDebugTarget.java:637)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget.access$4(FlexDebugTarget.java:1006)
at com.adobe.flexbuilder.debug.model.FlexDebugTarget.instantiateBreakpoint(FlexDebugTarget.java:1012)
at com.adobe.flexbuilder.debug.breakpoints.FlexLineBreakpoint.instantiate(FlexLineBreakpoint.java:465)
at com.adobe.flexbuilder.debug.breakpoints.FlexLineBreakpoint.findSourceFiles(FlexLineBreakpoint.java:412)
Attempted Fixes:
Cleaned project
Cleared browser cache
Tried different browsers (Yes, I have the debug player)
Deleted .metadata
Deleted workspace
Reinstalled Flash Builder
Reinstalled Debug Flash Player
Restarted Mac
Tried a different SDK
Reordered Java preference for both 32 and 64 bit configurations
Removed symlinks from project configuration (that is, symlinks are no longer needed to correctly find the build or run location)
Cleared Flash logs
Ensured no more than one version of the program was getting compiled (so it can't actually be running from another location)
Explicitly turned on debugging through compiler argument: -debug=true
Changing just about every relevant and lots of irrelevant settings within Project Properties
Project Details:
Interestingly, clicking on Actionscript Applications in the Project Properties results in Flash Builder immediately becoming unresponsive
Uses third-party libraries for functionality that may or may not be Debug builds
Uses third-party code for functionality that is included with the rest of the code via Actionscript Build Path > Source path (note that this folder must be included explicitly for this project even though the path included is already in the source directory)
Runs from a local web server, accessing local database using a custom domain that is not "localhost" nor an IP address (changed for Chrome cookie issues), rather it looks like http://programname.local/
Launch configuration starts the web browser at the correct local url (as opposed to starting up from a file), probably irrelevant
There is one additional compiler argument that simply creates a global, compile-time constant, probably irrelevant
Source and project directories contain svn repository folders and files, probably irrelevant
I have an NDA, so I can only talk about the project and its structure, I can't post code
Configuration:
Mac OS 10.6.8
Flash Builder 4 (through CS5)
Flex SDK 4.0 and 4.5.1
Figured it out. Our app uses a preloader which I had always gotten from others. I had assumed it was compiled to debug because I always got my copy from our debug server. I didn't fully understand how it worked or what it was doing.
Due to a Flash error in the preloader, this morning I was forced to compile it for the first time. Compiling it normally (as debug) I realized the problem with non-debug swfs loading debug swfs might apply here.
Breakpoints worked as expected once I correctly compiled the preloader and fixed its bug. Apparently our preloader is doing the actual loading of the main app. Flash Builder apparently can't handle this setup (non-debug loading a debug swf), whereas FlashDevelop apparently can.
Have you tried restarting your Mac?
I feel your pain, and your list of attempted fixes are what I'd try first :)
I had a similar situation to this and after hours of cursing Adobe I restarted my Mac and that solved it (probably some kind of memory error).