JsonLocalisation and WPF cannot find my translation files - json

My app runs in WPF and Android (Windows Phone later) with mvvmcross as framework. I implemented localization with JsonLocalisation like the Babel (N21) example and it is working fine in Android. But whatever I try in WPF I get this message;
mvx:Warning: 0,22 Language file could not be loaded for Danish.SettingsViewModel -
FileNotFoundException: Unable to find resource file MyAppResources/Text/Danish/SettingsViewModel.json
at Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxContentJsonDictionaryTextProvider.
LoadJsonFromResource(String namespaceKey, String typeKey, String resourcePath) at >Cirrious.MvvmCross.Plugins.JsonLocalisation.MvxTextProviderBuilder.LoadResources(String >whichLocalisationFolder)"
Stuart says in his video tutorial that the json translation files must be included as "Content" and not copied to the output folder - like;
But looking at the compiled executable with "dotPeek" doesn't reveal the files.
Am I missing something obvious? Any hints would be highly appreciated. Even confirmation from somebody who has JsonLocalisation working in WPF would be nice.
EDIT:
Well, I tried this code in my WPF mainWindow. I understand this call is used internally in MvxWPFResourceLoader.
public MainWindow()
{
....
//This return null without exceptions.
var t = Application.GetResourceStream(new Uri("MyAppResources/Text/Danish/SettingsViewModel.json", UriKind.Relative));
//This throwns an IOException; Cannot locate resource 'thisdoesnotexist/text/danish/settingsviewmodel.json'.
var y = Application.GetResourceStream(new Uri("ThisDoesNotExist/Text/Danish/SettingsViewModel.json", UriKind.Relative));
}
It seems when the path if wrong an exception is thrown. When it is correct it just returns null!!?! I am a bit puzzled, any ideas?
Best regards

Thank you for such fast answer (and for mvvmcross!).
The link you provided is to a Babel solution with a WPF sample - exactly what I needed. I mistakenly used the one from N21 without WPF sample :-)
Anyway, when looking at the sample I noticed that the json files must be included as 'Resource' and not 'Content'. That made all the difference - hurray!
Best regards

Related

Box API .NET SDK: "pad block corrupted" exception when instantiating BoxJWTAuth

I'm using the Box SDK for .NET and just trying to get started authenticating using the Java Web Token workflow. I'm using code that's pretty much the same as the code sample that's included in the SDK's code examples.
var jwtPrivateKey = File.ReadAllText("private_key.pem");
var boxConfig = new BoxConfig(ClientId, ClientSecret, EnterpriseId, jwtPrivateKey, JwtPrivateKeyPassword, JwtPublicKeyId);
var boxJwt = new BoxJWTAuth(boxConfig);
But at that last line I'm getting an exception that says "pad block corrupted". The stack trace seems to indicate that it involves reading the private key, but I don't see what I could be doing wrong considering this is basically the same as the code sample (https://github.com/box/box-windows-sdk-v2/blob/master/Box.V2.Samples.JWTAuth/Program.cs).
Any ideas?
After re-generating the private key with Cygwin, things are working for me.
I believe what happened was I opened the private key in Notepad or something, then saved it in some format it didn't like (maybe changed encoding to UTF-8, or saved it with Windows-style line breaks).

Html applet tag, accessing through chrome developer tools

i happen to receive a Html with an applet tag, is there a way to access the class received through chrome developer tools, i cant see it in the scripts. If there isnt how can i access it?
<applet name="tradesapp" id="tradesapp" code="loader3.SunLoaderApplet.class" archive="loader_20110113.jar" codebase="http://ih.advfn.com/" width="1100" height="2000" mayscript="" alt="This browser either has java disabled or does not support it" title="Java"><param name="manifestcrc" value="1211857157"><param name="storagepath" value="ih.advfn.com"><param name="masterloader" value="master"><param name="initial_focus" value="false"><param name="cache_archive" value="loader_20110113.jar"><param name="cache_version" value="1.0.7.7"><param name="java_arguments" value="-Dsun.java2d.d3d=false"><param name="advfn_url" value="http://ih.advfn.com/"><param name="streamer" value="stream-9.advfn.com"><param name="user" value="ih_340884"><param name="root" value="advfnclient.framework.BaseControl"><param name="page" value="advfnclient.TradesContainer"><param name="tz" value="US/Eastern"><param name="clearAllDateStamp" value="1272534624504"><param name="clearCacheDateStamp" value="1272534624504"><param name="language" value="us"><param name="view" value="ih"><param name="config_name" value="trades"><param name="config_default" value="Default"><param name="params" value="w=1100&h=2000&symbol=N%5EMSFT&montage=true&sources=afx:ukreg:rssnon&dims=664 79 15 0&col_widths=45 55 344 90 115&sid=1f58fa6b4ea88725c5b8e23d614a6e80&page_key=1338581393&w=1100&h=2000&pid=applet_embed&mypid=trades"><center><iframe width="600" height="300" src="/p.php?pid=javadisabled"></iframe></center></applet>
Chrome doesn't include a Java debugger and an applet isn't a script.
You can access it via document.getElementById('tradesapp'); in the JS console. If you want to do anything with it, then the applet will have to explicitly expose methods to JavaScript.
I suspect this is not your Java project, so I can't imagine Quentin's advice will help you. It sounds to me like you want to run the Java Applet yourself, perhaps making changes and having access to a debugger. I decided to see what I could do as I've never had experience with this kind of stuff before.
First of all, you can download the .jar file in the archive property. In your case it looks to be located at http://ih.advfn.com/loader_20110113.jar
You can then use Java Decomipler to decompile the .jar file. If you do so, you'll see that this jar file acts as a loader, and pulls more java classes from advfn.com. It saves them in the location given by:
String path = System.getProperty("user.home");
On windows this is C:\<USER>\advfn
You can decompile these classes as well if you're interested. You'll be left with an approximation of the original source code. In this case, a fairly good one.
If want you go one step further and decide to build the project yourself, you can import the classes into Eclipse. You'll notice there are some strange errors such as the following:
LoadFile(String paramLong, long arg3)
{
this.name = paramLong;
Object localObject;
this.size = localObject;
}
I've never built a decompiler myself and am not at all familiar with Java bytecode, but if I had to guess, I'd imagine that the decompiler was trying to represent a local instance of the argument that was passed in to it.
The fix is fairly obvious once you know this.size is of type Long.
LoadFile(String paramLong, long arg3)
{
this.name = paramLong;
this.size = arg3;
}
If you continue to make these changes, your code will compile successfully. But it still won't run as you're missing parameters set in the HTML. A sample line in LoaderApplet.java is as follows:
this.manifestCRC = Long.parseLong(getParameter("manifestcrc"));
If you return to the HTML page you found this at, you'll find a variety of parameters are specified there. You should be able to go through your project and replace requests for parameters with their appropriate values.
This was my first experience decompiling Java, so I might have missed a few details. Let me know if you need more help.

WkHtmlToXSharp - System.AccessViolationException

I'm using the WkHtmlToXSharp wrapper library in my project to generate PDF file from HTML.
I was using this library a lot of times in different PCs and, suddenly, I came across the following problem:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at WkHtmlToXSharp.WkHtmlToPdfConverter.wkhtmltopdf_convert(IntPtr converter)
at WkHtmlToXSharp.WkHtmlToPdfConverter.Convert(String inputHtml)
at WkHtmlToXSharp.WkHtmlToPdfConverter.Convert()
at WkHtmlToXSharp.MultiplexingConverter.b_8()
--- End of inner exception stack trace ---
at Sanford.Threading.DelegateQueue.EndInvoke(IAsyncResult result)
at Sanford.Threading.DelegateQueue.Invoke(Delegate method, Object[] args)
at WkHtmlToXSharp.MultiplexingConverter.Convert()
This seems to be a common problem with this library (I've found some feedback on the web about it - however no fix was provided). BTW, in my case it happens somewhat randomly. I was not experiencing this problem in other dev machines. I wonder if somebody has a fix for it. I also wonder if this is a problem with the wrapper library, if with the WkHtmlToPDF library itself.
Any suggestion? I'm also open to use another converter, as long as it is free and stable and, if possible, without spawning a new process. It must work properly and stable in all Windows versions and do a decent job converting (the HTML to be converted is fixed - contains a few pics and tables and basic CSS).
I would suggest an alternate route: simply use wkhtmltopdf.exe directly, building your own wrapper. They are not very complicated if you have control of the input and then you know exactly how to update it and how the options work. I've never encountered with that problem when using wkhtmltopdf directly (on Win7, Win server 2008 r2, Ubuntu and CentOS). They do spawn process for every conversion though.
For an example, check out the Derp class in another answer of mine regarding wkhtmltopdf. Or try something like the untested code below (your true code will be more complicated, this is just a demo/POC).
var pi = new ProcessStartInfo(#"c:\wkhtmltopdf\wkhtmltopdf.exe");
pi.CreateNoWindow = true;
pi.UseShellExecute = false;
pi.WorkingDirectory = #"c:\wkhtmltopdf\";
pi.Arguments = "http://www.google.com gogl.pdf";
using (var process = Process.Start(pi))
{
process.WaitForExit(99999);
Debug.WriteLine(process.ExitCode);
}

Error: Access of undefined property JSON ... but it IS there

I am developing a Flash application (Flash Player 11 as target platform) that uses the AS3 Facebook API, which in turn uses as3corelib JSON functionality. Or at least it should do so.
However, in spite of including the latest version (.93) of the as3corelib.swc, I still get the "Error: Access of undefined property JSON". I also tried including the sources directly, to no avail.
Any ideas what I am doing wrong?
As I said, the *.swc is definitely included. As is the source code (all at the correct path).
Edit:
I have a more specific error message:
Error: Can not resolve a multiname reference unambiguously. JSON (from C:\Coding\FlashDevelop\Tools\flexsdk\frameworks\libs\air\airglobal.swc(JSON, Walker)) and com.adobe.serialization.json:JSON (from C:\flash_test\lib\as3corelib.swc)) are available.
I know that JSON is included in AIR, but I do not target AIR, so why does it try include the airglobal.swc?
Your problem is that Flash Player 11 and onwards has native JSON support, so the JSON class you are including is likely colliding with the one from as3corelib. Hence the ambiguity problem.
Try removing as3corelib entirely and see what happens.
Specify the full path to the class. Example, code:
...
var jsonData:Object = JSON.decode(loader.data);
...
will be
...
var jsonData:Object = com.adobe.serialization.json.JSON.decode(loader.data);
...

ActiveX in HTML

My requirement is to instantiate an object using new ActiveX() in html.
I have created a COM component SimpleActiveX using ATL. I have created the dll SimpleActiveX.dll for the same. In order to instantiate this component in html file I need to register the dll. So I registered the dll using the command regsvr32 %Path of dll%.
After doing so I am trying to create and instance of the component in html file as follows,
var req;
req = new ActiveX("SimpleActiveX.Hello"); //Assume Hello as a class.
req.Hi(); //Assume that Hi() is a member function of Hello.
By doing so I am unable to create the ActiveX object.
Html doesnt give any error too. I dont know whether I am doing anything wrong or am I missing anything.
Could anyone please tell me the proper steps to perform above operations.
How do I need to create the dll (Here in this case I have just build the ATL project in Visual Studio to generate the dll)?
What else do I need to do with the dll in case if I need to create an ActiveX object in html?
I had come across something called as <object> </object> tag in html where we mention the classid and attributes. I dont know whether I need to mention this in my html file or not.
Thanks for your help in advance.
To instantiate an ActiveX object in JavaScript, assuming the dll is correctly registered, you just have to use:
var req = new ActiveXObject("SimpleActiveX.Hello");
Unfortunately I don't know how to register a dll using Visual Studio.
Regarding the tag, it is used when you want to embed the object directly in your HTML code, so that it will be instantiated when the document loads, instead of using JavaScript.
For example:
<object id="myObject" classid="CLSID:2D360200-FFF5-11D1-8D03-00A0C959BC0A"></object>
Then you can access the COM object with
var myObject = document.getElementById("myObject").object