I tried in XIDE to use Dynamic, but couldn't get it going.
The error I get is:
error XS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
This might be due to the bug Microsoft introduced that the target must be set to 4.5.1 at first, after which you can switch back to e.g. 4.6.2. In VS2015 this did the trick.
Note: after this, a reference to Microsoft.CSharp.dll is needed, to fix the compiler error Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'.
However, in Xide I can't find where I can set the target location, other to v2.0 and v4.0
Am I looking in the wrong places?
Regards,
Otto
DYNAMIC in XIDE
DYNAMIC in XIDE
Hi Otto!
I tried this also in c# and I got the same error! By trial and error, realized that you need to also add a reference to System.Core (in addition to Microsoft.CSharp). After doing that, it should work ok also in x#. Guess we should trap this situation and make the compiler report a better error message.
In XIDE, you don't need to set target .Net framework etc. Only time you might need to worry about this is if you must compile against .Net 2.0 only, but I think probably nobody needs to do this anymore..
Chris
I tried this also in c# and I got the same error! By trial and error, realized that you need to also add a reference to System.Core (in addition to Microsoft.CSharp). After doing that, it should work ok also in x#. Guess we should trap this situation and make the compiler report a better error message.
In XIDE, you don't need to set target .Net framework etc. Only time you might need to worry about this is if you must compile against .Net 2.0 only, but I think probably nobody needs to do this anymore..
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
DYNAMIC in XIDE
pmfji, just had a look with a "Basic x# app" and i get "Core does not exist in Namespace System" - after realizing for the x-th time, that reference is not using <g>, peeked into references, added reference to System.Core and Microsoft.CSharp. Trying to run MS sample:Chris wrote:you need to also add a reference to System.Core (in addition to Microsoft.CSharp). After doing that, it should work ok also in x#.Chris
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
i fail at the first line, how to define the "dyn" var. Unfortunately the "Dynamic" page of the help still has a "enter topic text", so i'm a bit at a loss..
BTW, "Dynamic" - and that after so many years of "you are dead meat, man, not using strong typed bla bla...."
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
DYNAMIC in XIDE
Hi Karl,
Probably you are (accidentally) using an older version of the c# compiler. Please go to Preferences/Compiler and set the c# option to the latest c# compiler executable. I think it should be
C:WindowsMicrosoft.NETFrameworkv4.0.30319csc.exe
But why testing this with c#, instead of x#?
Chris
Probably you are (accidentally) using an older version of the c# compiler. Please go to Preferences/Compiler and set the c# option to the latest c# compiler executable. I think it should be
C:WindowsMicrosoft.NETFrameworkv4.0.30319csc.exe
But why testing this with c#, instead of x#?
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
DYNAMIC in XIDE
Chris,
indeed, pointed to net2.0 version, changed that.
But didn't want to test with c#, took only the sample from MS site, translated to:
USING Microsoft.CSharp
USING System.Dynamic
FUNCTION Start( ) AS VOID
System.Console.WriteLine("Hello x#!")
// dyn := 1 AS DynamicObject ??? How to "declare" the var?
// should i "var dyn := 1"
LOCAL obj :=1 AS OBJECT
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType())
System.Console.WriteLine(obj.GetType())
dyn := dyn + 3
obj := obj + 3
RETURN
Sorry for confusion
indeed, pointed to net2.0 version, changed that.
But didn't want to test with c#, took only the sample from MS site, translated to:
USING Microsoft.CSharp
USING System.Dynamic
FUNCTION Start( ) AS VOID
System.Console.WriteLine("Hello x#!")
// dyn := 1 AS DynamicObject ??? How to "declare" the var?
// should i "var dyn := 1"
LOCAL obj :=1 AS OBJECT
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType())
System.Console.WriteLine(obj.GetType())
dyn := dyn + 3
obj := obj + 3
RETURN
Sorry for confusion
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
DYNAMIC in XIDE
Hi Karl,
That should be just
LOCAL dyn AS Dynamic // or System.Dynamic
It's very similar to having
LOCAL dyn AS USUAL
and you use it more or less the same way as you would with a USUAL.
And yes of course I hear your comment about strong typing and I mostly agree, although there are cases where the dynamic type can be very handy, same as USUAL can be handy in some cases in VO.
Chris
That should be just
LOCAL dyn AS Dynamic // or System.Dynamic
It's very similar to having
LOCAL dyn AS USUAL
and you use it more or less the same way as you would with a USUAL.
And yes of course I hear your comment about strong typing and I mostly agree, although there are cases where the dynamic type can be very handy, same as USUAL can be handy in some cases in VO.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
DYNAMIC in XIDE
Hi Karl, hi Chris,
I have a base class for MVVM like this
public abstract class ExpandoBase inherit DynamicObject implements INotifyPropertyChanged
and that works very well.
I can publish this class in the Pearls group.
Wolfgang
I have a base class for MVVM like this
public abstract class ExpandoBase inherit DynamicObject implements INotifyPropertyChanged
and that works very well.
I can publish this class in the Pearls group.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
DYNAMIC in XIDE
Dynamic works, System.Dynamic does NOT - "error XS0118: 'System . Dynamic' is a namespace but is used like a type".Chris wrote:Hi Karl,
That should be just
LOCAL dyn AS Dynamic // or System.Dynamic
It's very similar to having
LOCAL dyn AS USUAL
and you use it more or less the same way as you would with a USUAL.
And yes of course I hear your comment about strong typing and I mostly agree, although there are cases where the dynamic type can be very handy, same as USUAL can be handy in some cases in VO.
Chris
My Dyn (or usual) remark was more aimed at the evangelists of progress
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
DYNAMIC in XIDE
Hi Karl,
Oops, sorry!! Yes, there's no "Dynamic" type really, under the hood it's actually declared as System.Object and the rest is done by compiler trickery. I think I should make xide treat "dynamic" as a keyword, will do that for the next ver.
Chris
Oops, sorry!! Yes, there's no "Dynamic" type really, under the hood it's actually declared as System.Object and the rest is done by compiler trickery. I think I should make xide treat "dynamic" as a keyword, will do that for the next ver.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
DYNAMIC in XIDE
Hi Wolfgang,
Yes of course!! It's exactly for stuff like that that the pearls section was introduced.
Chris
Yes of course!! It's exactly for stuff like that that the pearls section was introduced.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu