I'm using a PCL version of Sqlite.net from https://github.com/oysteinkrog/SQLite.Net-PCL
This code below doesn't work for some reasons on WP8:
var sqliteFilename = Path.Combine(ApplicationData.Current.LocalFolder.Path, "MyDB.db3");
var db = new SQLiteConnection(new SQLitePlatformWP8CSharp(), sqliteFilename);
And I am receiving this error:
An exception of type 'SQLite.Net.SQLiteException' occurred in SQLite.Net.DLL but was not handled in user code
Additional information: Could not open database file: C:\Data\Users\DefApps\AppData\{149B7F85-2C71-4BEF-984F-903BA7DB80DA}\Local\MyDB.db3 (CannotOpen)
What I am doing wrong?
Thank you!!!
#Sergey-Chesalin thank you for your answers. I checked and found that it should create DB when it's not available. After my research I found why it doesn't work as it should.
For some reasons they add additional symbol to the connection string, see Line 121 in SQLiteConnection.cs and Line 196 in SQLiteConnection.cs. Maybe it works as expected in iOS/Android/WinRT versions of ISQLiteApi implementations, but it doesn't work as it should for Windows Phone.
So in order to fix it I have changed this line:
string dbFileName = Encoding.UTF8.GetString(filename, 0, filename.Length);
To this:
string dbFileName = Encoding.UTF8.GetString(filename, 0, filename.Length - 1);
in the SQLite.Net-PCL/blob/master/src/SQLite.Net.Platform.WindowsPhone8.CSharpSqlite/SQLiteApiWP8.cs line 12
Have you marked your database file file as content in project?
And you can explore deployed project with ISETool or something with GUI like this to check for file existence by this path.
Related
I'm trying to build a Flutter project on Xcode with firebase installed. I'm getting the following error: Property 'downloadURL' not found on object of type 'FIRStorageMetadata *'
This is being caused by the following section in the FirebaseStoragePlugin.m file:
NSString *path = call.arguments[#"path"];
NSDictionary *metadataDictionary = call.arguments[#"metadata"];
FIRStorageMetadata *metadata;
if (![metadataDictionary isEqual:[NSNull null]]) {
metadata = [self buildMetadataFromDictionary:metadataDictionary];
}
FIRStorageReference *fileRef = [[FIRStorage storage].reference child:path];
[fileRef putData:data
metadata:metadata
completion:^(FIRStorageMetadata *metadata, NSError *error) {
if (error != nil) {
result(error.flutterError);
} else {
// Metadata contains file metadata such as size,
// content-type, and download URL.
NSURL *downloadURL = metadata.downloadURL; <---------------- This line
result(downloadURL.absoluteString);
}
}];
}
Since I didn't generate this code, I don't particularly want to edit it as it should really be working out of the box. I've tried to change the method to see whether later versions of Firebase might only accept another function but to no avail. What shall I do in this situation? Should I perhaps try to rebuild the project with a higher version of Firebase or is there a one line fix?
The downloadURL was removed from the StorageMetadata class in May 2018. If your native iOS code still uses that, it's high time to find an updated SDK or update your code to match the documentation on uploading a file and getting its download URL.
If you're using the FlutterFire binding libraries, upgrade to the latest version (as I definitely don't see any reference to metadata.downloadURL in its current code base). If you're using another library, check if the latest version of that solves the problem - or otherwise consider switching to the FlutterFire libraries as those are quite actively maintained.
Does somebody know if/how it is possible to obtain the minor Visual Studio version that is currently running, from within a VSIX extension?
I've already found the following property, but we would like to have the more detailed version number (more parts). https://learn.microsoft.com/en-us/dotnet/api/envdte._dte.version?view=visualstudiosdk-2017
The following code shows "16.0.29306.81 D16.2" in my VS 2019:
var shell = (package as System.IServiceProvider).GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsShell)) as Microsoft.VisualStudio.Shell.Interop.IVsShell;
object ver = null;
shell.GetProperty((int)Microsoft.VisualStudio.Shell.Interop.__VSSPROPID5.VSSPROPID_ReleaseVersion, out ver);
System.Windows.MessageBox.Show(ver.ToString());
Assuming you may want the level like X.Y.Z instead of X.0 or X.Y. (e.g: VS2017-15.9.13=>15.9=>15.0).
Sergey's great answer can help you resolve the issue if the format X.Y is enough for you. But if you want to get the full details like VS version+version number, you can consider using registry key.
For VS2015 and earlier versions you can see this vsx document and this similar issue, you can try to use RegistryKey to access the info you want from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vs\Servicing\<version>.
But since the installation experience of VS2017 has changed for the vs installer.exe. We can't access the version details about VS2017 and VS2019 under that registry key any more.
For VS2017 and VS2019, I find we can access the related info at HKEY_CURRENT_USER\Software\Microsoft\VSCommon\15.0 or 16.0\SQM\PIDs\.
If in the machine only has one edition of VS2017 and VS2019, you can use code like this to get details:
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
string version = dte.Version;
string editon = dte.Edition;
RegistryKey key = Registry.CurrentUser;
RegistryKey pidsKey = key.OpenSubKey("Software\\Microsoft\\VSCommon\\" + version + "\\SQM\\PIDs\\", true);
string[] instances = new string[10];
instances = pidsKey.GetSubKeyNames();
RegistryKey instanceKey = key.OpenSubKey("Software\\Microsoft\\VSCommon\\" + version + "\\SQM\\PIDs\\" + instances[0], true);
//read the details about VSManifestID
string versionInfo = instanceKey.GetValue("VSManifestID").ToString();
The versionInfo's format see here: VisualStudio/15.9.13+28307.xxx (Apart from VSManifestID, you can also use VSChanelID...)
But this won't work if you have more than one edition of same VS version in PC.(VS20xx community and enterprise in same machine). In this situation you have to add much more judgement logic with the help of dte.Version and dte.Edition.
The easiest way to find the minor part of VS is to get version information from the file "devenv.exe":
var devenvInfo = FileVersionInfo.GetVersionInfo(dte.FullName);
return new Version(devenvInfo.FileMajorPart, devenvInfo.FileMinorPart);
I have a Xamarin UWP app and am trying to load a file from my current users "Documents" library.
I understand that I need to add a File Type Association declaration first. I've done this and the file icon has changed to my application icon.
In the app I'm then using the FilePicker plugin from here...
https://github.com/ArtjomP/FilePicker-Plugin-for-Xamarin-and-Windows
FileData file = await CrossFilePicker.Current.PickFile();
Byte[] data = file.DataArray;
All I do is browse to the file and select it, but the application crashes with an access violation on the second line.
I've added the following capabilities to my UWP manifest, not sure if they are event relevant anymore.
<uap:Capability Name="documentsLibrary" />
<uap:Capability Name="removableStorage" />
How do I open my files? I ideally need to use a convenient location like the documents library.
Nick.
Edit:
I've followed this article, and still no joy.
https://www.pmichaels.net/2016/11/11/uwp-accessing-documents-library/
You are using a old package which most likely is no longer supported.
Try this one, https://github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows
It is quite simple, and also supports UWP.
Sample usage
try
{
FileData fileData = await CrossFilePicker.Current.PickFile();
if (fileData == null)
return; // user canceled file picking
string fileName = fileData.FileName;
string contents = System.Text.Encoding.UTF8.GetString(fileData.DataArray);
System.Console.WriteLine("File name chosen: " + fileName);
System.Console.WriteLine("File data: " + contents);
}
catch (Exception ex)
{
System.Console.WriteLine("Exception choosing file: " + ex.ToString());
}
EDIT: I reworded the answer for clarity, and to avoid some implications that #MickyD rightly pointed in comments and I don't agree with those implications either:
This seems like a bug in the package as it doesn't work according to its documentation and one possible thing to do is to submit the issue to GitHub so that the bug is resolved by the developer of the package.
The other possible thing to do is to look for the alternatives. You may try to find other similar packages and see if they work, and the alternative for which I am sure that works is to use the native functions in System.Windows.Storage (as it is officially supported).
I am getting the following error when I try to start my Application...
[java.lang.IllegalStateException: java.lang.NullPointerException^M
at com.tivoli.pd.jutil.kb$1.run(kb$1.java:41)^M
at java.security.AccessController.doPrivileged(AccessController.java:229
)^M
at com.tivoli.pd.jutil.kb.c(kb.java:141)^M
at com.tivoli.pd.jutil.kb.(kb.java:56)^M
at com.tivoli.pd.jutil.PDContext.(PDContext.java:76)^M
at com.tivoli.pd.jazn.PDAuthorizationContext.(PDAuthorizationConte
xt.java:66)^M
I double checked the config file was accessible and I could read it. The code I am using looks as follows...
aC = new PDAuthorizationContext(cFile);
Is there a way to get more information on what is causing the NPE?
More information!!!
After debuging a bit, it appears the issue comes from this code (they use progaurd so it is a little hard to be 100% confident)...
Certificate[] arrayOfCertificate1 = ((KeyStore)???).getCertificateChain("DefaultID");
//Throws Null pointer (presumably because array is null)
Certificate localCertificate1 = arrayOfCertificate1[0];
EVEN MORE INFO
This appears to be some kind of dependency conflict (guess), because if I just create a sample App using PDAuthorizationContext it works fine.
Problem was related to the PD.jar version that I was using. Although I thought I was using one version I was using another. This was because on version was registered in my WebSphere library (under build path in eclipse). Once the proper library was introduced everything worked.
I'm new to ASP.NET and having a problem with a tutorial.
I've created a new MVC4 Project in VS2012 Express for Web.
And I've added a SQL Database with 1 Table "Persons" and filled it with some random testdata:
Id int (primary key, is identity=true)
name varchar(50)
birthdate date
adam 01.01.2001
berta 02.02.2002
As a Model I've used ADO.NET Entity Data Model, named it "PersonsModel.edmx"
and used the Personsdatabase for it.
To see the PersonsModel.Designer.cs file, I activated "Codegeneration Status" to "Standard". Refreshed and clicked on the PersonsModel.Designer.cs file.
But in this file I've errors... So I wanted to use something like this in my controller:
HomeController.cs:
PersonsEntities1 db = new PersonsEntities();
db.person...
but it doesn't work, and I think(?) it's because of the errors in the .Designer.cs file.
PersonsModel.Designer.cs: e.g.:
public PersonsEntities1() : base("name=PersonsEntities1", "PersonsEntities1")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
errors in the base: ... line
and in ContextOptions.
Unfortunately I've no english VS, but it says something like:
The best accordance für the overloaded System.Data.Entity.DbContext(string, System.Data.Entity.Infrastructure.DbCompiledModel)-Method has some invalid arguments
And no definition found for "ContextOptions", there is no method "ContextOptions" which accepts "MvcApplication7.Models.PersonsEntities1" as a first argument.
I'm a bit confused, because I did it like in the tutorial explained.
I think this code is in error:
base("name=PersonsEntities1", "PersonsEntities1")
There is no constructor that takes two strings. Your second argument is supposed to be of type DbCompiledModel. (See here.)
Now, I don't know why your designer would produce code that can't compile, so I'm wondering whether you have the wrong version of Entity Framework installed.
Apparently the problem was VS2012. It all works with VS2010.
I've downloaded the installer again from asp.net/mvc and added Visual Web Developer 2010 Express. After installation of VS2010 and all dependencies I tried the tutorial again and all works fine now. No wrong code in the .Designer.cs file :).
Thanks a lot Ann L. for your support. Your hint (wrong version of Entity Framework installed) prompt me to try another VS version.
In addition I've to say: I also tried VS2012 Ultimate (complete DVD version) but it didn't help.