MonoTouch/Three20: Add many items to the first page of TTLauncherView - c#

I observed some unexpected behavior with TTLauncherView from Three20.
After creating a standard view like this
var launcher = new Three20.TTLauncherView();
If I try to add TTLauncherItemitems like this
launcher.AddItem(item1, false);
launcher.AddItem(item2, false);
it creates a new page for each items.
Reading some Objective-C sample I came across something that would translate like this in C#, but it doesn't work neither, due to a System.MissingMethodException: Method not found: 'MonoTouch.Foundation.NSObject.IsNewRefcountEnabled' at runtime.
var items = NSArray.FromObjects(NSArray.FromObjects (item1, item2));
launcher.Pages = items;
So how would one go about adding many items to the first page of an TTLauncherView with MonoTouch using the official Three20 bindings?

System.MissingMethodException: Method not found: 'MonoTouch.Foundation.NSObject.IsNewRefcountEnabled
This error comes from bindings compiled with MonoTouch 5.1+ where a new refcount mode is available.
If you're using MonoTouch 5.0.x (latest stable) then you'll need to rebuild the Three20 bindings library to use them in your project.
Otherwise you can update to the latest MonoTouch (5.2.1) beta to use the binding binaries you already have. A stable release should be available soon so using the beta for a short term might be easier for you (than rebuilding the bindings).

Related

Call method from interface or abstract class within static void

I'm usually a javascript developer, but for my company I just started learning c# in order to use the CimatronE 13 API to develop custom command line PDM tools for this 3D modelling software.
As I'm making progress understanding the programming language, there's this frustrating situation where I want to use an API endpoint method but I can't manage to get it working.
The Cimatron documentation says the following:
IPdm::GetRelatedDocuments
Syntax: RelatedDocuments = GetRelatedDocuments ( DocumentPath );
This method allows you to get related files from compound types of files, for example Assembly or Drawing.
Input: (String) DocumentPath,
Path to file. For example \Documents\Location\Folder\Document. The file must be Assembly or Drawing.
Return: (Variant) RelatedDocuments,
Variant type array each element of which contain two dimensioned string type array of files related to selected one.
This looks pretty straight forward to me, so I tried calling it in multiple ways from within the static void Main() method, but I keep getting errors:
var RelatedDocuments = interop.CimBaseAPI.IPdm.GetRelatedDocuments("path");
CS0120: An object reference is required for the non-static field, method, or property 'IPdm.GetRelatedDocuments(string)'
interop.CimBaseAPI.IPdm pdm = new interop.CimBaseAPI.IPdm();
var RelatedDocuments = pdm.GetRelatedDocuments("path");
CS0144: Cannot create an instance of the abstract class or interface 'IPdm'
Any ideas? It's probably simple but I'm still a noob with c# :p
EDIT:
Cimatron documentation about the interface interop.CimBaseAPI.IPdm:
Properties:
Get
Query (String, DocumentEnumType, DocumentEnumUnit )
Variant
Methods:
A lot, including Variant GetRelatedDocuments ( String )
As how I see it now... interop.CimatronE.IPdm is an interface and in order to use it's methods, we first need access to the Cimatron application. Using the application object, we can use it's methods to get the desired interfaces such as IPdm and use their methods.
The following code gives no errors from the compiler but does when executing. This seems to be related to version 13 of CimatronE, since the application object works just fine using version 12. A lot has changed between these versions which I think is the reason the API is not functioning properly, outdated.
interop.CimAppAccess.AppAccess AppAcc = new interop.CimAppAccess.AppAccess();
interop.CimatronE.IApplication CimApp = /*(interop.CimatronE.IApplication)*/AppAcc.GetApplication();
interop.CimatronE.IPdm pdm = CimApp.GetPdm();
var RelatedDocuments = pdm.GetRelatedDocuments("path");
Console.WriteLine(RelatedDocuments);
Please correct me if I'm wrong! (since I just started and still learning c#)
I ran into this same issue with Cimatron 14.
I needed to make some changes in Visual Studio for things run properly with Cimatron.
Run Visual Studio in administrator mode
Set your Debug & Release Solution Platform to 'x64'
It was also recommended to point the build path for release & debug to the same folder as the Cimatron references. In my case 'C:\Program Files\3D Systems\Cimatron\14.0\Program'. However my code appears to run fine without this.
I created the Cimatron Application with this code (VB.Net):
Dim gAppAccess As New CIMAPPACCESSLib.AppAccess 'Define an AppAccess object to get running active application
Dim gApp As CIMAPPACCESSLib.Application 'Define an Application object
gApp = gAppAccess.GetApplication 'Getting running active application
If gApp Is Nothing Then
gApp = New CIMAPPACCESSLib.Application 'Creating a new instance of a Cimatron application
End If
References: Interop.CIMAPPACCESSLib.dll & interop.CimServicesAPI.dll
It is my understanding that Cimatron 15 may also requires some manifest changes.
There is some help information in the Cimatron program under Cimatrom Modules > Cimaton SDK that may be mildly helpful.

how to solve RDotNet REngine nullreference exception

I am trying to use the REngine.GetInstance() function but I keep getting a null reference exception.
I have tried using another function in REngine just in case the getInstance method was at fault, like REngine.SetEnvironmentVariables(), yet they all return the null reference exception.
I have tried reinstalling the package. I have tried checking the installation path but I couldn't find how the rdotnetlibrary accesses it. I am not even sure the path is related to the problem.
Please help.
Make sure your startupparameters are set up correctly. Since you do not provide us enough information; this is a correct way to get r.net's REngine running:
//...
StartupParameter rinit = new StartupParameter();
rinit.Quiet = true;
rinit.RHome = "C:/Program Files/R/R-3.4.3";
rinit.Interactive = true;
REngine.SetEnvironmentVariables();
rMain = REngine.GetInstance(null, true, rinit);
//...
Make sure you setup RHome to the correct installed R path.
EDIT (thanks to #David M.): In usual cases you only need to pass StartupParameter to GetInstance() if you don't want to have default initialization settings. However, according to the source code comments for the first parameter:
The file name of the library to load, e.g. "R.dll" for Windows. You usually do not need need to provide this optional parameter
In rare cases you need to provide the path of R.dll:
//...
rMain = REngine.GetInstance("C:/Program Files/R/R-3.4.3/bin/x64/R.dll", true, rinit);
//...
I've had the same issue using version 3.5.0
a call to "REngine.GetInstance" would result in 'Object reference not set to an instance of an object'
I downgraded to 3.4.0 and I'm not getting that error anymore.
When we upgraded R from 3.4 to 3.5, we got that exact error. We downgraded back to 3.4 and moved on.
As other answers have pointed out, this appears to be an issue relating to R 3.5 and above. I also managed to work around this by downloading R 3.4.4 and having both versions run concurrently, using Shique's solution.
For those unable to downgrade their R, it looks like jmp75 has been working on a fix, and there is a WIP branch available at https://github.com/StatTag/rdotnet/tree/r_3_5_0

Binding to Text property ios-unified not working

I updated my xamarin ios-project to the unified API (64 Bit support). Everything worked as expected. The project builds and works.
But I detected one problem. The binding to UILabel.Text properties won't work anymore. All other bindings are still working (to a UIButton.Hidden property for example). Here is my code:
// Create bindings
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(labelitem) // not working
.For(t => t.Text)
.To(v => v.MyStringValue);
set.Bind(buttonitem) // working
.For(b => b.Hidden)
.To(v => v.MyboolValue)
.WithConversion(new InverseBoolValueConverter());
set.Apply();
I'm using MvvmCross for the bindings. Bevore the unified-update everything worked fine.
First I tried to change the Linker-Option to "don't link". Same problem.
Can anyone explain me, what's happen? Thanks
Edit
I found a info in the output while debugging my project:
Weak Target is null in MvxUILabelTextTargetBinding - skipping set
There are some issues that some people are seeing, others are not, with the new GC in the latest Xamarin "stable" releases (maybe differences between VS and XS - it's not clear...). You can read about these on https://github.com/MvvmCross/MvvmCross/issues/902 (with some background on Migrating to Unified API and new reference counting)
There's an attempt to address these in http://slodge.blogspot.co.uk/2015/02/351-alpha-release.html - please do try the alpha packages to see if they help.
If not, then the only accepted workaround right now is to promote your UILabel to a private variable in your View.

How to fix Unity Container Warning: "ContainerElement.Configure(Unity.IUnityContainer) is obsolete"?

I have just installed Prism4 on my box and trying to get started working on a example of Unity (UnityContainer).
I am using SL4, Prism4, .Net Framework4, VS 2010 Ultimate.
I am getting a warning in the class Program.cs on line configSection.Containers.Default.Configure(container);
Microsoft.Practices.Unity.Configuration.ContainerElement.Configure(Microsoft.Practices.Unity.IUnityContainer)'
is obsolete: '"Use the UnityConfigurationSection.Configure(container,
name) method instead'
This is the code that I wrote:
var configurationSection = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
foreach (ContainerElement containerElement in configurationSection.Containers)
{
container =configurationSection.Configure(container, containerElement.Name);
}
I understand that the old method is deprecated and needs to be replaced, but how can this be done? The code I tried above seams to be not working correctly.
A previous method in the Unity library - Microsoft.Practices.Unity.Configuration.ContainerElement.Configure(Microsoft.Practices.Unity.IUnityContainer) has now been replaced with a new implementation UnityConfigurationSection.Configure(container, name).
It's telling you that the original method has been replaced by a new one the new version of the Unity library so just use the new method. If you want the legacy method you will need to use an old version of the Unity library.

How to add a property to a document type in Umbraco from code?

Could anyone give me an example of how to programatically add a property to an existing document type in Umbraco CMS? This is what I tried:
var dt = DocumentType.GetByAlias("TestDocType");
dt.AddPropertyType(new DataTypeDefinition(-49),"testprop", "test prop");
But it throws an exception:
Method not found: 'Void umbraco.cms.businesslogic.ContentType.AddPropertyType(umbraco.cms.businesslogic.datatype.DataTypeDefinition, System.String, System.String)'.
Any ideas?
I managed to fix it. The website was recently upgraded from Umbraco 4.5 to Umbraco 4.7.1, so the dll's had to be replaced with the more recent ones. In the older version of Umbraco the method's return type was public void AddPropertyType whereas the new one public PropertyType AddPropertyType. Apparently during the upgrade the new cms.dll wasn't copied over, so I copied it from a clean Umbraco 4.7.1 solution, changed the code to receive the return type and it helped.
Required namespaces:
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.businesslogic.web;
So the final code(assuming correct assemblies are referenced):
var dt = DocumentType.GetByAlias("TestDocType");
var pType = dt.AddPropertyType(new DataTypeDefinition(-49),"testprop", "test prop");
That code looks fine to me, it should work.
Make sure your first line is actually returning a documentype, not null.
Also, do you have the proper 'usings' in place, you'll need at least some of these?
using umbraco.cms.businesslogic.web;
using umbraco.NodeFactory;
using umbraco.cms.businesslogic.member;
using umbraco.cms.businesslogic.datatype;

Categories