SQLite UWP Error with Mobile EMulator Windows 10 - c#

I am getting the following error when I run the Mobile Emulator while trying to compile and run a VS 2015 UWP app. The app runs fine when using the Local Machine or Simulator.
System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for 'SQLitePCL.raw' threw an exception.
Source=SQLitePCL.raw
TypeName=SQLitePCL.raw
StackTrace:
at SQLitePCL.raw.sqlite3_open_v2(String filename, sqlite3& db, Int32 flags, String vfs)
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
at SQLite.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at App3.MainPage.LoadSQLData()
at App3.MainPage..ctor()
at App3.App3_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
at App3.App3_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:
HResult=-2146233052
Message=Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=SQLitePCL.raw
TypeName=""
StackTrace:
at SQLitePCL.SQLite3Provider.NativeMethods.sqlite3_win32_set_directory(UInt32 directoryType, String directoryPath)
at SQLitePCL.SQLite3Provider..ctor()
at SQLitePCL.raw..cctor()
I have the following references:
SQLite for Universal Windows 3.9.1
sqlite-net-pcl
Microsoft Visual C++ 2013 Runtime Package for Universal Windows
The code where the error occurs in the "using (var db......:
int recCtr = 0;
var root = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "BaseBallOU.db");
List<string> NHLCollection = new List<string>();
using (var db = new SQLite.SQLiteConnection(dbPath))
{
var NHLlist = db.Table<Teams>().ToList();
foreach (var item in NHLlist)
{
recCtr++;
NHLCollection.Add(item.TeamName.ToString());
}
}
I see a number of similar posts, but some are dated and not using the most recent SQLite libs and pcls.
I'm looking for the correct SQLite dlls, sqlite pcls, runtimes (e.g. VC++ 2013? And version numbers that can be used to compile and run a UWP app on both the local machine and phone emulator.
TIA

Following is how I work with SQLite:
Download and install Sqlite visual studio extension from http://sqlite.org/download.html
Create a new blank c# Universal Windows Platform app.
Right click on the References of project -> Add Reference -> Universal Windows -> Extension -> add SQLite for Universal App Platform and its dependency Visual C++ 2015 Runtime for Universal Windows
Right click on the project node -> Manage NuGet packages -> Search SQLite.Net-PCL -> Install the default version 3.0.5
Change your code to the following:
using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath))
{
...
}

Step 1: Install SQLite VSIX pacakge for Universal Windows Platform development using Visual Studio 2015
https://www.sqlite.org/2016/sqlite-uwp-3130000.vsix
Step 2: Install NuGet package SQLite.NET-PCL
PM> Install-Package SQLite.NET-PCL
Step 3: Add references
Add Reference -> Universal Windows ->Extensions -> Make sure the following packages have been checked:
"SQLite for Universal Windows Platform"
"Visual C++ 2015 Runtime for Universal Windows Platform Apps"
If you didn't add reference for VC++ 2015 Runtime, you will get an error mentioned that "Unable to load DLL 'sqlite3' in SQLite Net Platform WinRT" when creating DB connection.

Related

Error reading voices installed on Windows 10

I use this code to read the installed speech synthesizer:
System.Speech.Synthesis.SpeechSynthesizer oVoice = new System.Speech.Synthesis.SpeechSynthesizer();
But in debugging I see that it generates an error:
oVoice threw an exception of type 'System.PlatformNotSupportedException'
So when I run the next line of code:
var oV = oVoice.GetInstalledVoices();
I'm getting this error:
No entry installed on the system or no entry available with the current security setting.
But I have three voices installed, I checked in the control panel and tried them.
I don't understand why I get these errors.
I use Windows 10 Enterprise, Visual Studio 2010 (I have 2019 but I can't use it now) and Framework 4.0 (and I can't change it).

Xamarin.UITesting NU1201 Error: Android 8.1 Is incompatible with .NETFramework 4.6.1

Have been having a little issue for the last couple of days now where I will create a new Xamarin Forms project on Visual Studio 2017 and add a Xamarin.UITest Cross-Platform Test Project for unit testing I recieve a series of NU1201 Errors when I reference the .Android App in the UITest Project.
Here is the exact error i get:
Error NU1201 Project App1.Android is not compatible with net461 (.NETFramework,Version=v4.6.1) / win-x64. Project App1.Android supports: monoandroid81 (MonoAndroid,Version=v8.1)
I have played around with the Android version numbers to see if the UITesting package doesnt support the latest android but no matter what version of android i target the problem remains the same.
Here is a screenshot of the project.
All the code is unchanged from the default project and runs in the simulator fine but only produces these errors when the Android app is referenced to the UITest project.
Solved it after many more hours of testing and trialling. Instead of adding the Android project to the references, Within the AppInitializer I added another method to the StartApp() call like so:
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if (platform == Platform.Android)
{
return ConfigureApp.Android.InstalledApp("com.companyname.App1").StartApp();
}
return ConfigureApp.iOS.StartApp();
}
}
Therefore once I had already run the app via the emulator for the first time and installed on the device, the UITest simply uses the installed APK on the emulator instead of the project.
For those who ran into error NU1201, you might have come to the right place. This may not apply to the question asked but I ran into error NU1201 the other day and the reason for that is the nuproj configuration file for our nuget project has target configuration wrong. It should have been
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
instead of
<TargetFramework>net462</TargetFramework>
because the project is not of "SDK-style."
References: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-target-framework-and-target-platform?view=vs-2019

WP8 SQLite error: The specified module could not be found

I'm trying access a SQLite database from my Windows Phone 8 app but am encountering the following error whenever SQLite code is hit:
{System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
at Sqlite.Sqlite3.sqlite3_open_v2(String filename, Database& db, Int32 flags, String zVfs)
at SQLite.SQLite3.Open(String filename, Database& db, Int32 flags, IntPtr zVfs)
at SQLite.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
at TopoMap.Map.MapTileServer.<Initialise>d__0.MoveNext()}
I've installed the Visual Studio extension SQLite for Windows Phone (v3.8.4.3).
I've installed the sqlite-net-wp8 NuGet package (v3.8.4.3).
I've added SQLite.cs and SQLiteAsync.cs to my project.
I've added the USE_WP8_NATIVE_SQLITE conditional compilation symbol to my project.
The project runs fine with no issues until a line of code is hit that accesses the underlying Sqlite3 class.
Any ideas what the issue might be?
Delete all references to sqlite from solution
Install Sqlite for WP8 from http://visualstudiogallery.msdn.microsoft.com/cd120b42-30f4-446e-8287-45387a4f40b7
Restart Visual Studio. In my case it's Visual Studio 2013.
open your solution where you want to use sqlite
Using package manager console in order to install sqlite-net. Enter the following command: Install-package sqlite-net
Install sqlite-net-wp8. Enter the following command: Install-package sqlite-net-wp8
Add compilation cofiguration
7.1 Right-click the project and select Properties.
7.2 Select the Build tab.
7.3 In the Configuration list, select All Configurations.
7.4 In the Platform list, select All Platforms.
7.5 On the Build tab, you’ll see Conditional compilation symbols under the General header, containing a default value of SILVERLIGHT;WINDOWS_PHONE on a Windows Phone app project. Change the value to SILVERLIGHT;WINDOWS_PHONE;USE_WP8_NATIVE_SQLITE and save the project file.
Right-click References and select add reference.Go to Windows Phone -> Extensions and check the option SQlite for Windows Phone
It works for me!!
Good luck

How to install Google.GData SDK to Windows mobile

Installing google api package with "Install-Package Google.GData.Calendar" thru nuget package console works for installation part properly but, referenses downloaded by nuget is not valid reference file for windows mobile, and creates exception error file not found when running application.
I write this code in function
var feedUrl = "http://www.google.com/calendar/feeds/tr.turkish%23holiday%40group.v.calendar.google.com/public/full";
var service = new CalendarService("Calendar");
var qry = new EventQuery(feedUrl);
qry.StartTime = t1;
qry.EndTime = t2;
EventFeed results = service.Query(qry);
but program doesn't enter to code, directly creates exception,
Error Messages:
Google.GData.Calendar.DLL'. Module was built without symbols.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
when i search, find out that nuget package is good for desktop, and for mobile need to add google.gdata from source code.
Could you help, how to add google.gdata to WP8 project, i couldn't find the source code of the api's.
And don't know how to install it.
Thanks a lot for your help
You can find the new version of the nu-get package for Windows Phone here.
Google.Apis.Calendar.v3

Launching SharpDX/DirectX app with DeviceCreationFlags.Debug

I am trying to launch my directX/SharpDX app with DeviceCreationFlags.Debug but i am getting the following crash upon startup:
SharpDX.SharpDXException: HRESULT: [0x80004005], Module: [General], ApiCode: [E_FAIL/Unspecified error], Message: Unspecified error
at SharpDX.Result.CheckError()
at SharpDX.Direct3D11.Device.CreateDevice(Adapter adapter, DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels)
at SharpDX.Direct3D11.Device..ctor(Adapter adapter, DeviceCreationFlags flags, FeatureLevel[] featureLevels)
at SharpDX.Toolkit.Graphics.GraphicsDevice..ctor(GraphicsAdapter adapter, DeviceCreationFlags flags, FeatureLevel[] featureLevels)
at SharpDX.Toolkit.GamePlatform.CreateDevice(GraphicsDeviceInformation deviceInformation)
at SharpDX.Toolkit.GraphicsDeviceManager.CreateDevice(GraphicsDeviceInformation newInfo)
at SharpDX.Toolkit.GraphicsDeviceManager.ChangeOrCreateDevice(Boolean forceCreate)
at SharpDX.Toolkit.GraphicsDeviceManager.SharpDX.Toolkit.IGraphicsDeviceManager.CreateDevice()
at SharpDX.Toolkit.Game.InitializeBeforeRun()
at SharpDX.Toolkit.GameWindowDesktop.Run()
at SharpDX.Toolkit.GamePlatform.Run(GameContext gameContext)
at SharpDX.Toolkit.Game.Run(GameContext gameContext)
at wrapper.Program.Main(String[] args)
This is on Win7 32bit and i do have the June2010 DirextX SDK and Runtime installed as well as the Windows SDK for Windows 7.
btw, this question originated from this one: SharpDX crash when rendering h264 video using MediaFoundation
From the MSDN (page on D3D11_CREATE_DEVICE_FLAG):
D3D11_CREATE_DEVICE_DEBUG
Creates a device that supports the debug layer.
To use this flag, you must have D3D11*SDKLayers.dll installed; otherwise, device creation fails. To get D3D11_1SDKLayers.dll, install the SDK for Windows 8.
These files are not part of the June2010 SDK. You have to find them somewhere else (i.e. in the Windows 8 SDK, as suggested).
Alternative to installing the SDK is installing Visual Studio 2012 or newer. Its installation will install these debug libraries.
Similar problem was mentioned here: link => explanation 3

Categories