简体   繁体   English

Win8 Javascript Metro App,带有C#WinRT组件和SQLite

[英]Win8 Javascript Metro App, with C# WinRT Component and SQLite

I'm creating a Windows 8 Store App. 我正在创建一个Windows 8商店应用程序。 The front-end (main project) of this app is in HTML5/Javascript. 这个应用程序的前端(主项目)是HTML5 / Javascript。 And I'm following this guide by Tim Heuer to create a C# WinRT component that wraps SQLite calls and behave as a controller . 我正在按照Tim Heuer的指南创建一个包含SQLite调用并充当控制器的C#WinRT组件。 The front-end calls this component via Javascript, to update data, and get presentation content. 前端通过Javascript调用此组件,以更新数据并获取演示文稿内容。

So there are 2 projects in my solution, 'main' in javascript, and 'db' in C#. 所以我的解决方案中有2个项目,javascript中的“main”和C#中的“db”。 I've managed to get SQLite working according to the guide. 我已经设法让SQLite按照指南工作了。 The reason I have this structure is that I'm trying to port an app from iOS to Win8. 我有这种结构的原因是我正在尝试将应用程序从iOS移植到Win8。 The 'controller' part is an isolated component from the get-go, and it's already ported to C#. “控制器”部分是一个独立的组件,它已经移植到C#。

However, there is one caveat. 但是,有一点需要注意。 Because of this known problem , I have to remove the reference to C++ Runtime v11 from the 'db' project to make it compilable. 由于这个已知问题 ,我必须从'db'项目中删除对C ++ Runtime v11的引用,以使其可编译。 Though it runs fine in the development machine. 虽然它在开发机器上运行良好。

Then I got this test machine (samsung xe700t1a to be exact, Intel i5), I discovered that when 'debugging remote' on this test machine, Visual Studio won't deploy SQLite3. 然后我得到了这台测试机(三星xe700t1a确切地说是Intel i5),我发现当在这台测试机器上“调试远程”时,Visual Studio将不会部署SQLite3。 As a result, my SQLite calls fail with error: "Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" . 结果,我的SQLite调用失败并出现错误: "Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

According to the guide I mentioned previously, the point SQLite was made available via WinRT extension, is to make deployment automatic. 根据我之前提到的指南,SQLite通过WinRT扩展可用,是为了自动部署。

I'm wondering why this happens and how to make it correct? 我想知道为什么会发生这种情况以及如何使其正确? I'm also wondering if there's any certification problems for Windows Store for apps in this structure? 我也想知道这个结构中的应用程序是否存在针对Windows应用商店的任何认证问题?

I also came across this post and this post suggesting that it's currently not possible to use SQLite in a WinRT component. 我也遇到过这篇文章这篇文章暗示目前无法在WinRT组件中使用SQLite。 But it's too late for me to change now, and this project won't be possible without a hybrid structure. 但现在改变现在为时已晚,如果没有混合结构,这个项目将无法实现。

I found the solution. 我找到了解决方案。 I used the hint from this post , and it's very straightforward. 我使用了这篇文章的提示,而且非常简单。

What I have to do, is to create another project in the solution, with Output Type set to C# Class Library. 我要做的是在解决方案中创建另一个项目,输出类型设置为C#类库。 Move the reference to SQLite for WinRT, and sqlite-net (nuget) wrapper to this new project. 将引用移动到SQLite for WinRT,并将sqlite-net(nuget)包装器移动到这个新项目。 After that, I have to manually go through classes in sqlite-net, and change all the 'internal' classes to 'public'. 之后,我必须手动浏览sqlite-net中的类,并将所有“内部”类更改为“public”。

For the original controller project, I add using myclasslib; 对于原始控制器项目,我using myclasslib;添加using myclasslib; so that class definitions are found. 以便找到类定义。

Apparently this workaround will work flawlessly. 显然,这种解决方法将完美无瑕地运作。 SQLite3 is deployed, and there's no warning against missing reference. 部署了SQLite3,并且没有针对缺少引用的警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM