RuntimeBinderException in the CSASPNETWebsite sample solution of Facebook C# SDK - facebook

I just started the CSASPNETWebsite website which is a sample example site uses the c# sdk and the dynamic keyword
The main page contain the following code:
var fb = new FacebookClient(this.CurrentSession.AccessToken);
dynamic myInfo = fb.Get("me");
lblName.Text = myInfo.name;
I got the following exception:
'Facebook.JsonObject' does not contain a definition for 'name'
from
myInfo.name;
(or myInfo.id or anything else that should be)
the type of myInfo at runtime is Facebook.JsonObject, is it should be anything else?
I have added references to Facebook.dll, Facebook.Web.dll and Facebook.Web.Mvc.dll
Thanks in advance,
Alon.

Find my mistake:
The references I add were for DLLs in the .net35 folder (which not contain all the dynamic keyword) instead of the SDK instead of the .net4 folder.
problem solved.

Related

Accessing Raw Gamer Profile Picture

I am using the new XBox Live API for C# (https://github.com/Microsoft/xbox-live-api-csharp) for official access through a UWP app.
I am able to authenticate fine and reference the XBox Live user in context.
SignInResult result = await user.SignInAsync();
XboxLiveUser user = new XboxLiveUser();
Success! However, I can't seem to find an appropriate API call to return XboxUserProfile or XboxSocialProfile. Both of these classes contain URLs to the player's raw gamer pics. After reviewing MSDN documentation and the GH library it isn't clear to me how this is achieved. Any help is greatly appreciated.
The below sample should work if you meet the following pre requisits:
Reference the Shared Project that contains the API from your project and don't reference the "Microsoft.Xbox.Services.UWP.CSharp" project
Copy all source code files from the "Microsoft.Xbox.Services.UWP.CSharp" project into your project
Include the Newtonsoft.Json NuGet package into your project
Steps 1 & 2 are important as this allows you to access the "internal" constructors which otherwise would be protected from you.
Code to retrieve the profile data:
XboxLiveUser user = new XboxLiveUser();
await user.SignInSilentlyAsync();
if (user.IsSignedIn)
{
XboxLiveContext context = new XboxLiveContext(user);
PeopleHubService peoplehub = new PeopleHubService(context.Settings, context.AppConfig);
XboxSocialUser socialuser = await peoplehub.GetProfileInfo(user, SocialManagerExtraDetailLevel.None);
// Do whatever you want to do with the data in socialuser
}
You may still run into an issue like I did. When building the project you may face the following error:
Error CS0103 The name 'UserPicker' does not exist in the current
context ...\System\UserImpl.cs 142 Active
If you get that error make sure you target Win 10.0 Build 14393.

Copy a folder with Smartsheet API - Java SDK 2.0.5

I am trying to copy a folder with the Smartsheet API 2.0 (Java SDK 2.0.5).
Unfortunately the folders and sheets (all sub folders/sheets too) are copied but the sheet data is missing.
I get no errors everything works fine.
I tried several variants of the optional include parameters the ".ALL", "null", ...
This is the example code and the used environment:
Netbeans IDE 8.2
smartsheet-sdk-java-2.0.5.jar (with maven)
// Optional params
EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!
EnumSet skipRemap = EnumSet.noneOf(FolderRemapExclusion.class); // Remap all fields
// Specify destination.
ContainerDestination destination = new ContainerDestination.AddContainerDestinationBuilder()
.setDestinationType(DestinationType.FOLDER)
.setDestinationId(targetFolder.getId())
.setNewName(folder.getName())
.build();
smartsheet.folderResources().copyFolder(folder.getId(), destination, includes, skipRemap);
What am i doing wrong? Thanks a lot for your help.
Perhaps try changing this line:
EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!
To this instead:
EnumSet includes = EnumSet.of(FolderCopyInclusion.ALL);
(I'm not a Java expert, but the change I've suggested is consistent with the code example in the Smartsheet API Documentation.)

How to include another assembly in a Windows Phone 8 XAP

I would like to include another assembly in my XAP for Windows Phone without referencing it directly (like a plugin system) so I can load it at runtime and activate types from it but I can't find any kind of reference on this.
I mostly found out questions regarding how to load it once included but how to (correctly) include it, no.
You can add a compiled assembly (.dll file) to your WP8 project and set the file Build Action to 'Content'. Then you can try to load it as so :
var folder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "Plugins", "Services"));
var files = await folder.GetFilesAsync();
var firstFile = files.FirstOrDefault();
var assy = Assembly.LoadFrom(firstFile.Path);
But Assembly.LoadFrom will fail since it's unsupported. You can still use this to load other binary content but not code.
All you can do is reference all 'plugins' or whatever assemblies you might need and not directly reference any type from these assemblies. By 'reference the assemblies' I mean right click on references (in the WP8 project) and "Add reference...".
You can then do this :
var assy = Assembly.Load("MyCompany.MyProject.WhateverAssembly");
var tp = typeof(IService);
var x = ass.GetTypes().Where(t => t.IsClass && tp.IsAssignableFrom(t)).SingleOrDefault();
Activator.CreateInstance(x);
Not very elegant but I could call it a workaround.

QBO Queries and SpecifyOperatorOption

I'm trying to query QBO for, among other entities, Accounts, and am running into a couple of issues. I'm using the .Net Dev Kit v 2.1.10.0 (I used NuGet to update to the latest version) and when I use the following technique:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
(i.e. just create a new AccountQuery of the appropriate type and call ExecuteQuery) I get an error. It seems that the request XML is not created properly, I just see one line in the XML file. I then looked at the online docs and tried to emulate the code there:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
cquery.CreateTime = DateTime.Now.Date.AddDays(-20);
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.AFTER);
cquery.CreateTime = DateTime.Now.Date;
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.BEFORE);
// Specify a Request validator
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
unfortunately, VS 2010 insists that AccountQuery doesn't contain a definition for SpecifyOperatorOption and there is no extension method by that name. So I'm stuck.
Any ideas how to resolve this would be appreciated.

getting OSGI Bundle from Eclipse IConfigurationElement

I am looking for extensions that implement a specific extension point, and am using the following acceptable method to do this:
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
if (extensionRegistry == null) {
return TEMPLATES;
}
IConfigurationElement[] config = extensionRegistry.getConfigurationElementsFor("com.ibm.im.launchpoint.templates.template");
I then would like to get the version of the defining bundle. I would use the following API, but the API for PluginVersionIdentifier is deprecated:
for (IConfigurationElement e : config) {
BlueprintTemplate template = new BlueprintTemplate();
IExtension declaringExtension = e.getDeclaringExtension();
PluginVersionIdentifier versionIdentifier = declaringExtension.getDeclaringPluginDescriptor().getVersionIdentifier();
I could not find an alternative in the new API - i.e. from a IConfigurationElement, how do I get the version id descriptor of the bundle. Obviously, from the Bundle I can get the version using the Bundle.getHeaders(), getting the Bundle-Version value - but how do I get the Bundle in the first place??? Platform.getBundle(bundleId) is not enough since I might have multiple versions of same bundle installed, and I need to know who I am. At the moment I have a chicken & egg situation, and the only solution I have is the above deprecated API.
All this information is based on Eclipse 3.6:
Your IContributor will be an instance of RegistryContributor if you are in the osgi environment which of course you are or you wouldn't be having this issue.
RegistryContributor gives you two methods: getID() and getActualID(). getID() may return the host bundle if this was loaded from a fragment. getActualID() always loads the id of the fragment/bundle the contributor represents. You can use this id in your BundleContext.getBundle(long id) method. Here is a snippet:
Bundle bundle;
if (contributor instanceof RegistryContributor) {
long id = Long.parseLong(((RegistryContributor) contributor).getActualId());
Bundle thisBundle = FrameworkUtil.getBundle(getClass());
bundle = thisBundle.getBundleContext().getBundle(id);
} else {
bundle = Platform.getBundle(contributor.getName());
}
I use a fall through method that will degrade gracefully to a non-version aware solution if IContributor gets a new default implementation in the future. The bundle id is unique to an instance of OSGi so it will load the correct version of the bundle.
I suggest browsing a bit the Javadoc deprecation descriptions, the replacement is documented. I found the following code, but did not test it.
String contributor = e.getDeclaringExtension().getContributor().getName();
Bundle bundle = Platform.getBundle(contributor);
Version versionInfo = bundle.getVersion();
Out of curiosity: why do you need to get the version of the extending plug-in? As far as I know, the goal of the extension point mechanism is to detach specific information about the extender, and only the information described in the extension (plugin.xml) or the referenced code is needed.