Announcements
I know there's a simple answer, I've probably read it already but it's been a long day and I'm tired. Thanks in advance.
I have an azure D365 dev machine procured through LCS.
I have a c# class library called MyCSharpProj in my solution with one class
public class x
{
public bool boolVal { get; set; }
}
I've added a reference to the project in my solution from my "Dynamics 365 for Operations" "Operations Project"
I have a class in the operations project and the following method
public void test()
{
MyCSharpProj.x testVar = new MyCSharpProj.x();
testVar.boolVal = true; // this gives an error ' Invalid token "=" '
}
What is the correct way to be able to set the value from the c# class?
Aha, thank you for the update.
.NET Interop from X++ is getting better with every version, but it still has quite a few limitations. It will be great if you push for improvements internally. :-)
Resolved, my problem is that I have a c# class that exposes another class as a member. Apologies, I was not totally honest when I gave my initial example, I was trying to simplify it so as not to put a bunch of code into the example. Consider the following code
C#
namespace Ax365InvalidTokenTestClassLibrary
{
public class X
{
public bool BoolPropertyMember { get; set; }
}
public class Y
{
public bool BoolPropertyMember { get; set; }
}
public class Z
{
public Y y { get; set; }
public X x { get; set; }
}
public class a
{
public void test()
{
Z z = new Z();
// works fine here
z.y.BoolPropertyMember = true;
}
}
}
X++
class Class1
{
public void test()
{
Ax365InvalidTokenTestClassLibrary.Z z = new Ax365InvalidTokenTestClassLibrary.Z();
//not fine here, this is an error : Invalid token "="
z.x.BoolPropertyMember=true;
//But this works
Ax365InvalidTokenTestClassLibrary.X x = z.x;
x.BoolPropertyMember=true;
}
}
MyCSharpProj.x testVar = new MyCSharpProj.x(); works
testVar.boolVal = true; Doesn't work
I can't believe there are any Unicode issues, but thank you so much for taking a stab, this is a weird one.
As a test, I 've added a new c# class lib and referenced it with that code and it works for me as well. I'm going to start adding all of the pieces from my existing lib into the new one incrementally and see where it breaks, if it breaks. I'll let you know what the result is.
Your code looks fine and it also compiles without any problem, if I try it in my system.
It's interesting that the compiler doesn't complain about types, members or so; it fails in a much earlier phase, when it fails to recognize the token "=". Don't you have, by any chance, another Unicode character that looks like the equals sign, but it's technically something else? For example, ᐀ is "Canadian syllabics hyphen", not the equals sign.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148