[Q] PROBLEM SYSTEM NAMESPACE - Visual C++ - General Questions and Answers

Hi!!
I'm developing a custom app on visual studio 2008 with visual c++: smart device win32 project with CF 3.5 (same problem on 2.0) for WM6.
It's my first WM app so I'd like to learn how all is workin and not just how to make all work!!
Anyway my app involves a Timer, a serialized FileWriter (to save config parameters taken from user interface) and some bluetooth tasks.
I discover that CF doesn't support binary file writers and the timer class contained in System::Windows::Forms.. i solved this task tryin to use XML file writer and System::Threading::Timer.
(msdn.microsoft.com/en-us/library/aa446549.aspx here i have what is supported and what is not)
But here i had the main problem:
'System' : is not a class or namespace name
'System' : a namespace with this name does not exist
I had this one everytime i try to use features of System namespace, i googled this problem and he answered to compile with '/clr' opt .. ye i know i have to do that but it works just on usual win32 project!!!
There isn't '/clr' opt on smart device's property page!!! I think cause you can't apart from managed code in this kind of project (??).
Does someone know how to solve this?
I can't believe we cannot use System nsp in mobile programming -.-'
Thanks to all!!!
Yuri

So.. i begin understanding that the main problem is stupid use of managed and native code. I got that this is not solvable just in vc++ and absumed that just VB and C# can handle mixed programming (both managed and native) i decide to:
Create the mainapp in vb that handle the form control (to get user input data) and the timer.
In the methot that handle the ElapsedTimerEvent call a MY.dll compiled with VC++ in MFC for CF. This lib will contain method for xml file writing and Bluetooth tasks.
Does someone know if this kind of approach contains any error??
Best Regards
Yuri

Related

SQL CE 3.5 - First App

I'm working on developing my first WM 6 App using SQL CE 3.5 . I'm sure there are other apps out there that do what mine does, but I'm just wanting the experience of developing it.
I'm working on a fairly simple app to track gas mileage and such. But, for some reason, whenever I debug it, the app can't seem to find the database file. I get an error saying: "The database file cannot be found. Check the path to the database. [ Data Source = .\GasTrackerDB.sdf ]"
I can browse with file explorer on the device and find the database in the same directory as the deployed application, so I'm not really sure where to go from here..
I'm doing everything through the IDE, so all of the code is generated for me to connect to the database.
Anybody experienced enough to help me troubleshoot this stupid problem?
i have been looking for an app that does the same thing as the one you are working on.
when it is finished please pm me. i wish i knew more programing, if i did i would help you.
Try
Code:
string database = string.Format(@"{0}\GasTrackerDB.sdf", GetApplicationPath());
public static string GetApplicationPath()
{
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
return path;
}
I did figure it out after messing around with it. I think it has to do with the way VS2008 deploys the app on the emulator...
When I hard-code the path to the database file, it works. So, my app will just have to be installed on the local device and not the SD card
Don't hard-code the path! The method GetApplicationPath() returns the application path. This is also important when installing on OS with different language.
heliosdev said:
Don't hard-code the path! The method GetApplicationPath() returns the application path. This is also important when installing on OS with different language.
Click to expand...
Click to collapse
How is that possible when the Connection String was generated by the IDE? Here's what the .xsd says:
Code:
<Connection ConnectionStringObject="Data Source=\program files\gastracker\GasTrackerDB.sdf" IsAppSettingsProperty="false" Modifier="Assembly" Name="GasTrackerDBConnectionString" ParameterPrefix="@" Provider="Microsoft.SqlServerCe.Client.3.5" />
On application start create the connection string "Data Source = " + database (like post #3)
This connection string can then be passed wherever you need to connect to the database.
That's the problem.. the IDE created all the stuff for the connection string and I don't know enough about it to create everything needed manually.
How do you connect to the db? What are you calling for retrieving data from db? How do you insert data to the db? All these actions need an object which somehow knows the connectionstring. And this string can/must be changed.
Hmm.. That doesn't seem to be a valid function name. I'm using .NET CF 3.5 .I'll keep looking.
Well, I wrote my own function to get the execution path, but I still can't figure out how to modify the connection string at runtime.
This crap is ridiculous. I don't understand why it doesn't "just work" when I let the IDE do everything...
Well, I FINALLY made it work.. i ended up going through the xsd file and changing all the code that creates queries. I had to replace every instance of:
Code:
CType(Me._commandCollection(0), Global.System.Data.SqlServerCe.SqlCeCommand).Connection = New Global.System.Data.SqlServerCe.SqlCeConnection("Data Source=.\GasTrackerDB.sdf;")
With:
Code:
CType(Me._commandCollection(0), Global.System.Data.SqlServerCe.SqlCeCommand).Connection = New Global.System.Data.SqlServerCe.SqlCeConnection("Data Source=" & GetAppPath() & "\GasTrackerDB.sdf;")
That had to be done for every one of my queries created through the designer. Thankfully I only had 5!
Great! Keep in mind that changes in generated code can get lost when the ide is recreating the code. Just keep an eye on it when doing changes in this area!
heliosdev said:
Great! Keep in mind that changes in generated code can get lost when the ide is recreating the code. Just keep an eye on it when doing changes in this area!
Click to expand...
Click to collapse
Yeah, I already ran into that one If it gets to be too much of a pain, I'll see if I can create some sort of compile time script to do a find and replace.. But I haven't spent enough time going back and fixing it yet
go to
http://www.connectionstrings.com/
They have everything you need to build your connection string. From my experience, it's okay to let the IDE build everything EXCEPT the connection string....

[Q] Can a P/Invoke be used to call native APIs?

Since I'm not strong in C++, is it possible in a native/hybrid app to use a P/Invoke call to call native APIs from C# code?
So far what I have seen is COM interop where you have to code the bulk of what you want to do in native C++.
Any possibility here and if so how?
No. At least not that we know of. You have to create COM wrappers for native functions.
Various Marshaling APIs, which makes P/Invoke tick, are off-limits.
WP7 apps run under silverlight - the best place to learn about the security model and why p/invoke is not possible is here:
http://msdn.microsoft.com/en-us/library/dd470128(v=vs.95).aspx
As you can see the restriction is quite deep routed in the framework.
It still might be possible to run proper .NET CF executables in the future though if we can get it installed.
pInvoke
I just met a guy today, who successfully published WP7 app, that uses pInvoke - he just filled the Technical Exception form and ... done
It's used for muting system volume when the phone is in range of specified WiFi network (using BG agent) - for example when in range of school Wifi, turn the speaker off.
http://www.windowsphone.com/en-US/apps/6813ea1f-8d71-4ad5-a6d2-f80c193c6ac9
Can anybody confirm this actually works? He haven't tested it, because it won't work in emulator and even not in default developer unlock.
Here's the code he used, disassembled from the app:
http://pastebin.com/PfFm9Wxg
Do you know about any other apps, except apps from OEMs and Microsoft, that use pInvoke?
This gave me an idea, what else could be possible using small use of pInvoke? Maybe even something lot of users are asking for, like battery status on the start screen, who knows?
Thread Moved To WP7 Q&A​
This is a development section, not Q&A. Please post in the correct section!​
OK, a few things:
P/Invoke not working is *very* well documented. The DllImport attribute *appears* to be available, but calling a function that uses it invariably fails. The work-around for native code access is to use COM. There's also a project to re-implement DllImport.
Native code access has been available to homebrew developers for about a year, now. There are many apps which use it, ranging from web servers to registery browsers to yes, even an app that shows your battery status as a live tile on your Start screen...
These apps are not, however, permitted by Microsoft's Marketplace rules. It may be possible to get an exemption (some Marketplace apps do use native code) but by default, all apps that try to use native APIs (either via COM or P/Invoke) are automatically detected and rejected during analysis of the app prior to its approval.
As for the code you linked, it doesn't even compile (WP7 doesn't include CharSet.None, apparently). If you remove the CharSet directive, or if you set it to CharSet.Auto, it will compile but fails when used. You also didn't include any of the #using directives (OK, without the # in C#). Better would have been to just send us the XAP directly (yes we can get it, but a copy/pasted smidge is a lot less useful)
Downloaded the XAP. It's a paid app, so many tools won't find it.
Examining now. Nothing exotic so far. Possibly P/Invoke only works on signed apps?
The actual message signature that I see:
[PreserveSig]
[DllImport("coredll.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int waveOutGetVolume(IntPtr device, out uint volume);
Note that CharSet.Ansi still doesn't seem to exist. That said, this might simply be due to an outdated interop library that shipped with NoDo, and the Mango one does support this? More investigation...
"Possibly P/Invoke only works on signed apps?"
That's the question! If this actually works, it's possible we can get exception for more pInvoke calls and it might be even possible to certify app in marketplace for showing battery status or similar goodies. It won't be possible using that dllImport project, that's more than sure, but if we use only well defined set of safe pInvoke calls, we might get submission exception. It's definitely worth finding it out, what's possible here

[Q] how execute/apply xml file?

Hello,
I have a lot of problems with omnia 7 due to app profile network of samsung haven´t got the profile of my operator. I can set it thanks to a post of here, but I think that it is a bit difficult and you need the computer to set it. As I have studied some of programming c#, I decided to make an app that set mms and internet. I have already done the screen and I´ve get to make that app create the file xml with the code in order to set mms and internet, but I haven´t found information about how execute/apply the file xml with the app. Where can I find about it?
PD: Sorry, I do not control English very well
Hi,
I guess it's a topic a bit complex, but can not someone help me with this?
You use an OEM COM interface, accessed from C# by using Microsoft.Phone.InteropServices.ComBridge. One easy way to see how this is done is to look at the source of an app that does it. If you can't get the source to DiagProvXML, you could always just decompile it (decompiling .NET code is pretty easy and there are several tools that can do it). There are several other apps that also use provxml; one or more of them may offer source access.
Hi,
Thank for your help and I can select the services that I have load, but I have a small problem that I hadn't taken into account. I know c# but my apps are a lot of more easy that diagprovxml, and I can´t find the part of program that I´m interested. I use "JustDecompile" to decompile the app. Could you tell me what class(or classes) is (are) what I'm looking for?
Thank you very much again
Hmm... it's not linked in my SIG because it's out-o-date, but you could try using Search to find my old DeployProvXml app. It includes a pretty straightforward example of using provxml.
Essentially, you need the following things:
The interopservices DLL (allows you to use the ComBridge class).
The OEM DLLs (DMXMLCOM.dll and such).
COM class and interface definitions for them in C# (this is the stuff with the [ComImport] attributes and the GUIDs).
ID_CAP_INTEROPSERVICES in your WMAppManifest.
WPInteropManifest.xml file in your project.
Use the ComBridge to register the COM interfaces, then create an instance of the COM class(es), cast to the appropriate interface type(s), and use a variable of the interface type like any other .NET object.
You can read a bit more about COM and native code in Heathcliff74's guide. It's aimed at making your own native libraries, so skip all the stuff about creating your own COM classes and writing native code. http://forum.xda-developers.com/showthread.php?t=1299134
Hi again, Does the method WP7RootToolsSDK.Environment.ProcessConfigXml allow to set the parameters that have a tipical xml file?
thank you again
I'm not sure what you mean by "set the parameters" but the Root Tools SDK does in fact allow you to consume ProvXML files now (I think it even supports the query provXML and returns the output, though I haven't tried).

[Q] Conversion to Dalvik format failed with error 1 - Tried many solutions

Okay I know there are a bunch of these topics out there, but I have tried just about everything I could find and still I cannot get it to work. I have worked with my project for about 6 months with no errors, I stopped for 3 months and got back into it on a new computer and now it keeps giving me this error when trying to export a signed APK. I have tried the following:
Turning off Build Automatically (and cleaning the project many many times)
Tried Android Tools fix project settings
Changing the proguard.bat to include %1 %2 %3 etc
Removing the libraries from the Java Build Path > Libraries
Uninstalling Eclipse and Reinstalling the new version
Using the new Android ADT Studio
Removing the SDK's and downloading all the new SDK's
I am getting very frustrated and 7500 lines of code in, I dont feel like just starting over. Any suggestions on what steps i should take next?
This is the console error I am receiving:
Code:
[2014-11-08 17:48:57 - ZombieBird-android] Dx
trouble processing "java/io/BufferedInputStream.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
[2014-11-08 17:48:57 - ZombieBird-android] Dx 1 error; aborting
[2014-11-08 17:48:57 - ZombieBird-android] Conversion to Dalvik format failed with error 1
bump -> still trying to figure this out, and help would really be appreciated as I cannot really continue any further with my project.
Thank you!
Can someone please help? I'd really appreciate it....

Help for starting developing

Hi Guys,
I wanna start developing apps for the gearS2. Foir now I have some experience with html and several other languages mainly for windows applications and also last programming job was like 6 years ago so I'm not really up to date with all the different options for developing.
For start I tried to use the tizen SDK but I'm a little lost due to the variaty of options and also the quite buggy SDK. Installing the 2.4 SDK left me with an error for the simulator (hax not working). I t hink i got arround this by installing this manually. Emulator works now but for example the UI builder doesnt work. So my thought is to start a web app with tau as this seems to work quite reliable. My goal is to write a basic control of my hue lights (I know there is an app for that but I wanna try to build my own). My plan is to use an java lib for the hue commands and do the rest via the tau/html/javascript.
Now my question is if anyone can give me any advice on how to start developing. Does my plan seem valid. Can anyone help me or give me some tips? Maybe I'm missing something or someone just has some shortcuts.
Thanks in advance.
Björn
Hi.
I found this "howto" : http://www.tizenexperts.com/2015/12/how-to-deploy-to-gear-s2-smartwatch/
It helped me to successfully deploy a project sample on my gear s2 folllowing these steps :
- install sdk
- generate & configure author certificate.
- download, compile and run/deploy a project sample on the gear s2 (SensorBall).
During the "Request the Certificate" step, I ran into this java exception :
Unhandled event loop exception No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
Click to expand...
Click to collapse
I'm on "debian jessie" with "openjdk7":
If this happens:
- install package "libwebkitgtk-1.0-0"
- add "-Dorg.eclipse.swt.browser.DefaultType=webkit" to you "eclipse.ini" file
- restart tizen.
At the end, you'll have a new app installed on your watch. You can recognized it with the tizen icon.
I hope this can help you.
Bye.
thank you for your feedback akaiah.
I found this site earlier, requested a certificate but then I couldnt find the site again. So thx for the link.
My problems are more linked to
a) the general structure of webapps for tizen
b) rusty coding skills (last time i coded was 6 years ago and mainly c# / object pascal for windows)
c) problems with tau / it's documentation
Maybe someone can help with a few detailed questions.
First question is regarding the online samples. I've found the following code in one sample for wearables (calendar app) but I don't know what this is and if I should be using stuff like this. It doesn't look like standard javascript to me but I can't find any API/library included either:
Code:
/**
* App module.
* @requires {@link Calendar/views/initPage}
* @namespace Calendar/app
* @memberof Calendar
*/
define({
name: 'app',
requires: [
'views/initPage'
],
def: function appInit() {
'use strict';
/**
* Initializes the app.
* @memberof Calendar/app
*/
function init() {
console.log('app::init');
}
return {
init: init
};
}
});
Second question is regarding jquery. Which version should I use and how am I supposed to include this? I'm using the 2.4 SDK download but programming a wearable web app with 2.3.1. I tried inlcuding jquery by downloading the latest version 2.1.4 (uncompressed) and putting it in my lib file folder, then including it in the html header. I have the feeling though that this is causing some issues. E.G. some notations don't work:
Code:
$( "#divname" ).innerHTML = "newtext";
doesnt work. No error just no result.
Third question is regarding tau. I tried to create a popup and register a callback for the popupafterclose-event like this but it doesn't work (event is not fired)
HTML:
<!--Popup HTML code-->
<div id="popup" data-role="popup">
<p>This is a completely basic popup, no options set.</p>
</div>
<script>
// Use popup events
var popup = document.getElementById("popup");
popup.addEventListener("popupafteropen", function()
{
// Implement code for popupafteropen event
});
</script>
taken form HERE
What am I doing wrong here? Is this the correct API im looking here or maybe does it collide with the jquery library?
For any tips I would be very thankfull.
Greetings
Björn
Wow thanks finally some one. I wold love to root my device ..
If theres a way.
If anyone was wondering about this issue, I kind of got this solved.
I just started an new project copied over all code and removed my jquqery imports and the code that gave me errors before just works fine. TAU in generell seems to be quite buggy and is easily be destroyed by an "unlucky" combination of UI changes (opening a popup or another window).
Even a week later I still don't know what the code in the calendar sample is from and tau seems not to be the most stable library out there. If anyone else has trouble starting developing for this I'm happy to share more experiences.
Greetings from germany

Categories

Resources