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

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.

Related

Windows Universal App SQLlite in Portable DLL

My project structure is defined like this:
LIB Com basic communication, (requests and responses)
LIB Com.BackgroundTask background task that will fetch new messages from server
LIB Com.Mediator background logic that will handle every exchange of information and interaction between Com and the ViewModel
LIB Model all Models for the Project, also the Databases should be defined here.
LIB Settings App settings.
Windows App Views/Controls for Windows
Windows Phone App Views/Controls for Windows Phone
Shared Basic App logic, Mediator init, ViewModels
the Problem is that you cannot reference the SQLLite extension in the (Portable) LIB Model but this is essentialy for the project structure to work. Otherwise the BackgroundTask would never be able to update the Database, am i right?
You can refer SQLite in a portable class library project using Portable Class Library for SQLite. This project has been initiated by Microsoft Open Technologies, Inc. working with the community.
This portable class library for SQLite available as NuGet package
simplifies the installation and development experience for .NET
developers by providing a single interface across Windows Phone,
Windows Store and .NET Framework 4.5.
With this solution .NET developers can develop against one portable
class library and do not have to worry about what assembly is loaded.
Drawback: Targeting x64 platform architecture is not supported at the moment.
Targets supported: x86, and AnyCPU (with "Prefer 32-bit" option marked).
Pre-requisites:
1) The developer visits http://sqlite.org/download.html, and downloads the required precompiled binary for Windows v3.8.5 (http://sqlite.org/2014/sqlite-dll-win32-x86-3080500.zip), extracts the sqlite3.dll file, and adds it as Copy-Always Content to the root folder of the project.
2) In Visual Studio, the developer uses NuGet Packet Manager Console to install the SQLitePCL wrapper package.
Inside the Package Manager Console, type: Install-Package SQLitePCL

Cannot find type System.SystemException in module mscorlib.dll when reference to Microsoft.Phone in Windows Phone 8.1 app template

Microsoft just released Windows App 8.1 with combination of Windows 8.1 and Windows Phone 8.1, so you can create a universal app. However, it gives me a trouble to add Microsoft.Phone 8.1 assembly to project reference.
Here is what I did (in Visual Studio 2013, with Rc2 installed)
1> Create New project from Visual C#->Store Apps -> Windows Phone Apps.
2> Added Microsoft.Phone from this location: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.1
3> Now, do a build, I see the following Error: "Cannot find type System.SystemException in module mscorilib.dll"
Anyone has the similar experience? any solutions?
Thanks
There has been a few API changes as part of programming model in windows phone 8.1 apps.
have a look at this link.
It will solve your problem.
http://blogs.msdn.com/b/paraswadehra/archive/2014/08/21/how-to-send-email-from-your-windows-phone-8-1-app.aspx

Compile Windows DLL for WP8

I've got the c# source for a DLL that works on windows 8... I would like to use it in a windows phone 8 application. Is there an easy way to change the target platform of the project to WP8 and then compile for that? I assume it will have to be compiled as a Windows Phone Class Library but that should be fine. I'm using VS2013.
Well it depends on the library. If it has any dependencies to the full .net framework, it will most likely not work. If its just a generic Library, you should be able to make a new Windows Phone Class Library Project and copy over the source.
I guess, you'd simply have to try that. Maybe you can bypass some of the dependencies and rewrite these sections with Windows Phone compatible code.

WP8 - Re-using a native DLL through Windows Runtime Component

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.

I'm getting build errors when using MvxEventToCommand within a WP8 project

I'm using the MvvmCross framework to create a windows phone 8 project.
In my WP8 project within the xaml I have the following:
<i:Interaction.Triggers >
<i:EventTrigger EventName="Tap">
<Commands:MvxEventToCommand Command="{Binding OnItemTappedCommand}" />
</i:EventTrigger >
</i:Interaction.Triggers>
My namespaces are as follows:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
and
xmlns:Commands="clr-namespace:Cirrious.MvvmCross.WindowsPhone.Commands;assembly=Cirrious.MvvmCross.WindowsPhone"
When I attempt to build I get the error:
Cannot resolve dependency to assembly 'System.Windows.Interactivity, Version=3.8.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
Looking in ILSpy I can see that Cirrious.MvvmCross.WindowsPhone.dll references this dll but I only have version 3.9.5.0 available in my assembly references list within my project.
I've tried adding an assembly redirect in my app.config but I think that's more for runtime resolution then for build errors.
What's the best way to resolve this issue?
Thanks
-- EDIT --
I've managed to resolve this issue by finding a WP7.1 version of the System.WindowsInteractive.dll which is version 3.8.5.0. My project is definitely targeting the Windows 8.0 phone OS.
Could this be a problem with the Nuget packaging of MVVMCross?
Just to answer this question since I came across this problem today...
I had a fresh install of Windows 8.1 and the Windows Phone 8 SDK. My sln would build but when MvvmCross resolved the plugins on start-up it would crash with a ReflectionLoadTypeException - the LoaderExceptions property contained a single entry - it was unable to find System.Windows.Interactivity, despite being referenced from the extensions list in the reference manager for the project.
The solution was to install the Windows Phone 7 SDK and grab the Windows Phone 7 version from C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Windows Phone\v7.1\Libraries\System.Windows.Interactivity.dll.