System.Drawing.RectangleF : Persisting in Application Settings - settings

I'm trying to persist a RectangleF in Application settings, but it produces error message:
Type 'System.Drawing.RectangleF' is not defined.
I can save a string, and then parse to float, but I can't find an explanation to this:

Related

Not able to read int values from Kubernetese config maps

I am trying to deploy a springboot application on kubernetese. I have stored all environment variable in config map and trying to read value from there. There are certain properties where we need to read int values.
In our code, it looks something like this :
application.properties :
TOKEN_RETRY_COUNT=3
As we have to read it from ConfigMap, we have updated our application.properties as mentioned below:
Update application.properties :
TOKEN_RETRY_COUNT=${STARGATE_TOKEN_RETRY_LIMIT}
Config Maps
The values are configured are like this in the Config Maps. I had to put double quotes as it wasn't allowed without any quote.
"STARGATE_TOKEN_RETRY_LIMIT": "3",
Now, when I am trying to read these values after deploying it on kubernetese, I am getting below error :
For STARGATE_TOKEN_RETRY_LIMIT :
Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "STARGATE_TOKEN_RETRY_LIMIT"
For now, I had updated code to take this value as String and then parse it as int but this is not ideal way. There should be some standard way to take different types.
If we can't handle different type in Config Maps, then what what would be ideal way to pass different application properties for Springboot application on kubernetese ?
I don't think the issue is related to the property value (3) being specified as a string ("3"). If you read the error message carefully you will see that the NumberFormatException is caused by an attempt to parse STARGATE_TOKEN_RETRY_LIMIT (literally) to a an int. Probably there is something wrong with the way the config map is passed to the application/container.

Error when creating ACL in Cloud Code: invalid permission type

TL;DR
Setting an ACL with a role permission fails sometimes because the role's name is interpreted as the permission type.
The setup
In a Cloud Code function, I create an ACL object and use setRoleReadAccess to grant read access to a role:
const roleName = 'foo'; // this string is actualy calculated, but always non-nil and non-empty
const acl = new Parse.ACL();
acl.setRoleReadAccess(roleName, true);
Then I set that ACL to a new (unsaved) object:
const myObject = new MyObject()
myObject.setACL(acl);
The error
The setACL call causes an exception with the error message Tried to create an ACL with an invalid permission type. which seems strange since I didn't provide a custom permission type.
What I tried so far
I tried to set the role as a Role object instead of a string, but that didn't make a difference.
After some debugging I found that the error originates in ParseACL.js (line 85), where the permission string must either match read or write; however, in my case that string matches the role name (in the example above "foo").
I have similar ACL/role code in other parts of my app, so I'm sure this should work. Now I'm looking for hints -- what might cause the weird behavior that the role name is interpreted as permission type -- and tips on how to further debug this issue.
(Using parse-server version 2.3.3 and node.js 6.4.0; I'm currently locked to that Parse version.)
The issue was caused by having global.Parse = require('parse/node') in a global Mocha test setup file; when running all integration tests (> 300 tests, taking about 4 minutes) this caused some weird effects like the mentioned Tried to create an ACL with an invalid permission type, but also You cannot use [object Object] as a query parameter; both errors only occurred when the runtime was under heavy load and running all tests -- just running a single test never produced any errors.
Details in this Github issue.

How to parse Integer value as keys in YAML File

I am running a spring boot project where I need to parse an erro code dynamically, but I have realised that if the key is of integer type, it return null. Is there a way to parse Integer Keys in YAML file
Parsing This property doesnt work
errorcode:
00001: An error occurred whilst trying to process your request. We would like to apologise for the inconvenience.
Howver Parsing This property work
errorcode:
ONE: An error occurred whilst trying to process your request. We would like to apologise for the inconvenience.
I am trying to read this property using
import org.springframework.core.env.Environment;
#Autowired
private Environment environment;
error= environment.getProperty("errorcode.ONE") Works
error= environment.getProperty("errorcode.00001") --Doesn't works
So in nutshell, if an integer has been used as a key, YAML file is returning value as null. One workaround is to use the key this way as shown below, but any better ideas?
error
code-001:
It can be solved by specifying that number as string in yaml. like,
errorcode:
'00001': An error occurred whilst trying to process your request. We would like to apologise for the inconvenience.
This worked for me.
Read all string from the yaml and replace the integer value with non integer value. Descerialize the class with non integer value as variable.

A null reference or invalid value was found [GDI+ status: InvalidParameter]

I am running an MVC3 app on Mono/linux and everything is working fine with the exception of an image upload utility. Whenever an image upload is attempted i get the Invalid Parameter error from within the method below:
System.Drawing.GDIPlus.CheckStatus(status As Status) (unknown file): N 00339
System.Drawing.Bitmap.SetResolution(xDpi As Single, yDpi As Single)
I've googled this error extensively and have found that the Invalid parameter error can often be misleading, and could fire if for example there was an error with the upload itself, or if the image was not fully read. This runs fine on IIS/Windows, but I've not been able to get it to work in Mono.
Apache2
Mono 2.10.8.1
Am i missing something simple or do i need to find a different way to handle image manipulation for mono?
After doing quite a bit of testing, I was able to determine the root of my error. I was attempting to use the Image.HorizontalResolution and Image.VerticalResolution properties for Bitmap.Resolution . While these properties were set on the initial upload (where the file is read into a stream from the tmp directory), when i posted back with the base64 encoded string of the image itself, it appears these values were lost somehow. Because of this the SetResolution method failed.
For whatever reason i do not have this issue on IIS/Windows, the properties exist in both circumstances.
I encountered a similar issue. A Bitmap loaded from disk, reported bmp.HorizontalResolution==0 and bmp.VerticalResolution==0 when they were both==300. This behaviour does not occur on Windows.
A bit more digging, I found that the following test fails:
[Test]
public void GDI_SetResoltion()
{
var b1 = new Bitmap (100, 100);
Assert.That (b1.HorizontalResolution, Is.Not.EqualTo (0));
Assert.That (b1.VerticalResolution, Is.Not.EqualTo (0));
}
I believe Windows will default resolution to 96 dpi.

AppScript issues with Cocoa NSString and AppleScript text types?

In one of my Applications I've added a few new properties to the document class of the Standard AppleScript suite. Some of these properties have the type text, others have the type boolean. I've written a "sdef" file and added if to the resources of my App.
But when I launch the App, there are messages in the Console like this:
.sdef warning for type 'text' attribute 'title' of class 'window' in
suite 'Standard Suite': AppleScript name references may not work for
this property because its type is not NSString-derived.
And when I actually try to get the value from such a new property with type text from within an AppleScript, it will fail. The correct method within my App is called, and it returns the correct value as NSString, but the AppleScript returns with an error. There's a message in the Console again:
Error while returning the result of a script command: the result
object... "the requested NSString value" ...could not be converted to
an Apple event descriptor of type 'text'. This instance of the class
'__NSCFString' returned nil when sent -objectSpecifier (is it not
overridden?) and there is no coercible type declared for the scripting
class 'text'.
Which probably means that it was not possible to convert the Cocoa NSString object into an AppleScript text object.
When I try to get the value from one of the new boolean properties, it works just fine.
What exactly do I need to do to convert a NSString object into an AppleScript text object?
I suspect you need to coerce the text parameter into a NSString.
I.e
Set sometextString to current application's NSString's stringwithTring:atext
Use it in your method
And to return it you do.
Return sometextString as text

Resources