Binding to Text property ios-unified not working - c#

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.

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

Workflow Foundation 4.5 "Expression Activity type 'CSharpValue`1' requires compilation in order to run."

I am working through the Getting Started Tutorial for WF45 and have run into a problem that looks to have been experience by other people, but not in the same way that I am experiencing it. I am hoping that someone else has a solution for me.
When I work through the Tutorial, all is good till I have to run it from the workflow host. At that point the instantiation of the workflow fail and returns the following message.
"Expression Activity type 'CSharpValue`1' requires compilation in
order to run. Please ensure that the workflow has been compiled."
I have tried downloading the source from Windows Workflow Foundation (WF45) - Getting Started Tutorial in case I had missed a step but the error still persists.
Reading online it seems that workflows with embedded C# expressions need to be complied, but as I understand it this happens by default when using VS2012 and the workflow designer? I have tried to implement the CompileExpressions method found here but that did not help. I did read that there was a problem during the pre-release version where C# expressions caused this problem, and yet VB projects worked. Testing this, I see that I am suffering this exact case. The VB tutorial runs fine, but the C# version fails with this exception.
Furthermore and dare I mention it: This is not a problem on my colleague's machine, so I think it is a configuration problem on my machine...
Update & dodge fix:
So, I have managed to fix the problem, although I am not happy with the solution and would love to hear if anyone has a decent reason for this happening.
My fix was to replace my Microsoft.Common.targets file in the \Framework\v4.0.30319 folder with my colleague's version of the same file. This has solved the problem. What else it has broken remains to be seen...
The original Problem thread is pretty old, but may be your find that helpfull either.
I had the same Problem with my dynamic activities and found that the documentation is wrong:
This is the code which produces the error above:
string path = #"myActivity.xaml";
Activity activity = ActivityXamlServices.Load(path);
IDictionary<string, object> dictionary = new Dictionary<string, object>
{
{ "Arg", 1},
};
IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);
and this is the working code:
string path = #"myActivity.xaml";
ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
{
CompileExpressions = true
};
Activity activity = ActivityXamlServices.Load(path, settings);
IDictionary<string, object> dictionary = new Dictionary<string, object>
{
{ "ArgNumberToEcho", 2},
};
IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);
This might help someone - what worked for me was I had line breaks in the Expression window for one my of Assigns. Removed the line breaks and it started working.
Another cause of this error is when an expression has too many \r\n in the value.
So if you had an Assign activity with something like this for the "Value" section
new myobject(){
param1=val1,
param2=val2,
param3=val3,
param4=val4,
param5=val5,
param6=val6,
}
Change it to this:
new myobject(){param1=val1,param2=val2,param3=val3,param4=val4,param5=val5,param6=val6,}
Now hold both thumbs and hope it fixes the error.

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

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).

"The invocation of the constructor on type 'TestWPF.MainWindow' that matches the specified binding constraints threw an exception."- how to fix this?

I'm working with WPF. When I'm trying to declare SQLiteConnection in the code, the problem arises-
The invocation of the constructor on type 'TestWPF.MainWindow' that matches the specified binding constraints threw an exception.
InnerException: Make sure that the file is a valid .NET Framework assembly.
can anyone tell me, how to fix it?
If you click on View Detail... from the exception window you can look at the InnerException. Expand that node and you will see exactly what went wrong.
In my specific case, I was getting this because I had a few of my referencing assemblies mismatched between x64 and x86. Apparently I was binding to something that needed to be loaded by the runtime.
I mention this here as a reminder to check your build configurations if you've looked everywhere else!
I fixed the problem by adding the below content in app.config,
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true" /> </configuration>
I found this via a community addition by user FCAA below the article "
Troubleshooting Exceptions: System.IO.FileLoadException" on MSDN.
I got the same error and, after wasting about 2 hours with it, found that it is my SQL Server service that's not running. Not sure if this can ever help someone, but it did solve my problem to just start the service.
The mentioned exeption is quite generic and you can receive it, for instance, when code fails in the constructor. I had a case of an IO exception that showed up with a similar text. Stepping into the code may provide hints to fix this that may not be obvious otherwise.
I got it in when I specified the FrameworkPropertyMetadata of a DependencyProperty with a default value
the defaultValue was
new AdressRecord { Name = "<new>", Adress = "?" }
i replaced with
default(AddressRecord)
and vs2015 ate it
public static readonly DependencyProperty AdressRecordsProperty =
DependencyProperty.Register("AdressRecords",
typeof(ObservableCollection<AdressRecord>),
typeof(PageViewModel),
new FrameworkPropertyMetadata(
default(AdressRecord),//This noes not work: new AdressRecord { Name = "<new>", Adress = "?" },
OnAdressRecordsChanged));
I ran into this issue and it was caused because my startup application was built as any CPU but I was referencing a project that was built as x64. Setting the startup to build x64 resolved the issue.
In VS2015 I was able to see the specific code causing this problem once I turned on 'Enable Just My Code' in the Debugging Options under Tools -> Options.
I had this error in another part of code which has to do with my application resources.
This was fixed after explicitly setting the ResourcePath folder in my App.config file
I had the same problem. i could make it work by renaming the name of App1.config to App.config. I tried all other methods but the solution for me was to change the default name (for me it was App1.config) of the config file to App.config. I shared this because someone may get help by this small modification.
My problem was about the interface. I fixed it by deleting the Betternet folder that is located at C:\ProgramData.
Hidden Items/Folders must be shown in order to be able to view the folder.
With Visual Studio it will sometimes not show anything in the exception details or even have them, running the diagnostic tool however can easily pinpoint what is wrong.
Try Adding "Integreted Security = True" in Connection String.
It worked for me.
In my case it happened in a code-first WPF project. The cause was model changes after restoring a backup, and the error was not being handled appropriately. "The model backing the 'MyDataContext' context has changed since the database was created." Update-Database sorted it out.
I had to change the target .Net framework from 4.5.2 to 4.
my issue was regular System.IndexOutOfRangeException error in my own code,
but received this weird error because my code was called inside:
public MainWindow()
{
InitializeComponent();
// my code with error
}
same issue, if call it inside:
private void Window_Initialized(object sender, EventArgs e)
{
// my code with error
}
Fixed, if I call my code inside:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// my code with error
}
Then i get correct error message for IndexOutOfRangeException in my code.

Categories