Slartoolkit Solution Error - windows-phone-8

I'm getting a very strange error in relation to an AR project I'm working on, I am getting a System.NullReferenceException' occurred in SLARToolKit WinPhone.DLL" error in relation to a specific line of code being highlighted, that being:
private static Marker LoadFromResource(string relativePath, int segmentsX, int segmentsY, double width, System.Reflection.Assembly assembly)
{
var asmName = new System.Reflection.AssemblyName(assembly.FullName).Name;
using (var markerStream = Application.GetResourceStream(new Uri(asmName + ";component/" + relativePath, UriKind.Relative)).Stream)
{
return Load(markerStream, segmentsX, segmentsY, width);
}
}
Specificially this line is being highlighted:
using (var markerStream = Application.GetResourceStream(new Uri(asmName + ";component/" + relativePath, UriKind.Relative)).Stream)
This code is found in a "Marker.cs" file which I'm guessing is part of the SLARToolkit.DLL. Any ideas why I'm getting this error? Thanks in advance.

Related

DuplicateKeyException on the submitchanges method- Windows Phone

I am learning on how to insert data into the database using Linq and also to the ObservableCollection.
The data gets inserted into the ObservableCollection but not to the database. Could somebody explain whats going on with the code below. The system throws an unhandled exception on submitchanges method. Please advice.
public void populateDates(DateTime theWeek)
{
ObservableCollection<theSchedule> theDatesList = new ObservableCollection<theSchedule>();
for (int i = 0; i < 7; i++)
{
theSchedule theShift = new theSchedule
{
theDay = (theWeek.AddDays(i).ToString("dd/MM/yyyy")),
theTime = (theWeek.AddHours(i).ToString("HH:mm")) + " - " + (theWeek.AddHours(i+8).ToString("HH:mm"))
};
theDatesList.Add(theShift);
//MessageBox.Show(theWeek.AddDays(i).ToString("HH:mm"));
shiftsDb.theSchedules.InsertOnSubmit(theShift);
}
shiftsDb.SubmitChanges();
mylistbox.ItemsSource = theDatesList;
}

“Padding is invalid and cannot be removed” using AesManaged

I am getting error "Padding is invalid and cannot be removed."
when trying to decrypt file contents in chunks(using buffer). I am able to decrypt whole file at once but not in blocks. I found many links regarding this problem and most of them suggested to set Padding of AesManaged object
like aesManaged.Padding = PaddingMode.None
But this property is not available in window phone application.
Below is method:
internal static byte[] DecryptBytes(byte[] cipherText, string password)
{
// Check arguments.
if (cipherText == null || cipherText.Length <= 0)
throw new ArgumentNullException("cipherText");
byte[] decryptedBytes= new byte[cipherText.Length];
using (var rijAlg = new AesManaged { KeySize = 256, BlockSize = 128 })
{
var key = new Rfc2898DeriveBytes(password, Encoding.UTF8.GetBytes(Salt));
rijAlg.Key = key.GetBytes(rijAlg.KeySize / 8);
rijAlg.IV = key.GetBytes(rijAlg.BlockSize / 8);
// Create a decrytor to perform the stream transform.
ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV);
// Create the streams used for decryption.
using (var msDecrypt = new MemoryStream())
{
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Write))
{
csDecrypt.Write(cipherText, 0, cipherText.Length);
csDecrypt.FlushFinalBlock();
}
decryptedBytes = msDecrypt.ToArray();
}
}
return decryptedBytes;
}
Please suggest issue in above code or any other workaround
Don't use aesManaged.Padding = PaddingMode.None it will only hide the error, not solve it. You would get the error for incorrectly derived keys, incorrect ciphertext or - for smaller ciphertext - incorrect IV.
Print out the values of all the inputs in hexadecimals right before you perform the decrypt, then compare them with the ones obtained for encryption.

Type Error #1009 in flash cs6 using AS3

I am actually trying to check whether a game's score is a high score. And then if it is, the score will be added to the leaderboard.
However I got this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashGame_fla::MainTimeline/checkBananaHS()
In my game, in that particular frame, this is the code that would link to the checkBananaHS():
function rpslsWon():void
{
gameOverBananaMC.visible = true;
bananaWinLose.visible = true;
bananaWinLose.text = "Kampai " + cPlayerData.pName + "! You are totally bananas!! \nYour Score: " + pBananaScore;
toMenuBtn.visible = true;
rollAgainBtn.visible = true;
toMenuBtn.addEventListener(MouseEvent.CLICK, Click_backtoMain);
rollAgainBtn.addEventListener(MouseEvent.CLICK, backtoBanana);
saveItBtn.addEventListener(MouseEvent.CLICK, checkBananaHS);
cPlayerData.pBananaScore = pBananaScore;
saveData();
tracePlayerData();
}
And this is the piece of code in the high score's frame:
var rpslsHighScore:int;
var rpslsHSName:String;
rpslsHighScore = 0;
rpslsHSName = "";
//rpslsHighScore = 0;
bananaWinnerDisplay.text = " ";
bananaScoreDisplay.text = "0";
function checkBananaHS(event:MouseEvent):void
{
if ((cPlayerData.pBananaScore > rpslsHighScore ||
rpslsHighScore == 0) && cPlayerData.pBananaScore > 0)
{
trace("There's a new high score for Banana");
rpslsHighScore = cPlayerData.pBananaScore;
rpslsHSName = cPlayerData.pName;
bananaScoreDisplay.text = "" + rpslsHighScore;
bananaWinnerDisplay.text = rpslsHSName;
saveData();
}
}
I just can't manage to fix the error. Can anyone help me out? Thanks alot!
One of your variables within checkBananaHS() are not set when it is called. So when you try to access a property of that object, it errors out because nothing exists.
Wit that in mind, that means one of the following objects are not yet set in your function:
cPlayerData
bananaScoreDisplay
bananaWinnerDisplay
Run a trace on each of those, one at a time at the beginning of your function, and see which one doesn't return [Object object]

AS3 load variables from a txt file which has && formatting

I'm trying to load a txt file of variables into my AS3 project. The problem I have though seems to be down to the fact that the txt file (which is pre formatted and cannot be changed) is formatted using double amphersands... e.g.
&name=mark&
&address=here&
&tel=12345&
I'm using the following code to load the txt file
myLoader.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlRqSend = new URLRequest(addressToTxt.txt);
public function onLoaded(e:Event):void {
trace(myLoader.data);
}
Using URLLoaderDataFormat.VARIABLES generates the following error:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
If I use URLLoaderDataFormat.TEXT I can load the data successfully but I'm not able (or don't know how to) access the variables.
Would anyone have any ideas or work arounds to this please.
Thanks,
Mark
I had that kind of problem some time ago.
I suggest you to load first as a text, remove those line breaks, the extra amphersands and parse manually:
var textVariables:String;
var objectVariables:Object = new Object();
...
myLoader.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);
myLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlRqSend = new URLRequest(addressToTxt.txt);
public function onLoaded(e:Event):void {
textVariables = myLoader.data;
textVariables = textVariables.split("\n").join("").split("\r").join(""); // removing line breaks
textVariables = textVariables.split("&&").join("&"); // removing extra amphersands
var params:Array = textVariables.split('&');
for(var i:int=0, index=-1; i < params.length; i++)
{
var keyValuePair:String = params[i];
if((index = keyValuePair.indexOf("=")) > 0)
{
var key:String = keyValuePair.substring(0,index);
var value:String = keyValuePair.substring(index+1);
objectVariables[key] = value;
trace("[", key ,"] = ", value);
}
}
}
I wrote that code directly here, I don't have any AS3 editor here, so, maybe you'll find errors.
If you have data in String and it has a structure just like you wrote, you can do a workaround:
dataInString = dataInString.split("\n").join("").split("\r").join(""); // removing EOL
dataInString = dataInString.slice(0,-1); // removing last "&"
dataInString = dataInString.slice(0,1); // removing first "&"
var array:Array = dataInString.split("&&");
var myVariables:Object = new Object();
for each(var item:String in array) {
var pair:Array = item.split("=");
myVariables[pair[0]] = pair[1];
}
That should make you an object with proper variables.

AS3 What's wrong with this code?

Most of this is working and even with the error, it continues to work in part:
// Make PostItNote MC draggable and keep ON TOP
mcMXredBox.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
var q:int = 1;
// Add multiple copies of PostItNote when used
function fl_ClickToDrag(event:MouseEvent):void
{
event.currentTarget.parent.startDrag();
event.currentTarget.parent.parent.setChildIndex(DisplayObject(event.currentTarget.parent),87);
var my_PIN = new postItNote();
my_PIN.name = "my_RTC" + q; // Doesn;t like this line
this.parent.addChild(my_PIN);
trace("my_PIN = " + my_PIN);
this.my_PIN[q].x = 1388.05; // Doesn't like this line
this.my_PIN[q].y = 100;
q++;
}
The error is
TypeError: Error #1010: A term is undefined and has no properties.
at postItNote/fl_ClickToDrag()[postItNote::frame1:71]"
my_PIN.name = "my_RTC" + q; // Doesn;t like this line
This means that name is not a property of the postItNote class.
this.my_PIN[q].x = 1388.05; // Doesn't like this line
You seem to be using the wrong syntax here. What you want is probably just:
my_PIN.x = 1388.05; // In this context, my_PIN already refers to the movie clip named '"my_RTC" + q'