PC Review


Reply
Thread Tools Rate Thread

[C#][PPC]how can I use CompilerServices with CF (not supported) ?

 
 
=?Utf-8?B?RnJlZGR5Ym95?=
Guest
Posts: n/a
 
      1st Mar 2005
Hi,

I'd like to use System.Runtime.CompilerServices with the Compact framework
because I want to execute code which is in a string like that :

int i = 0;
string action = "i = 2;";
????.Execute(action);
Console.Writeline ("La valeur de i est: " + i);

In the compact framwork, System.Runtime.CompilerServices is not supported.

Somebody knows a solution ?

Thanks.

Best Regards.
 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      1st Mar 2005
How much flexibility do you need? if you just need to set the value from a
string use:-
string val = "2"; //perhaps this comes from a data file etc

int i = 0;

i = Integer.Parse(val);

Console.Writeline ("La valeur de i est: " + i);

If you have a finite number of operators you could write code in a switch
block so depending on the contents of your string e.g. "+=", "=", "-=". If
you also need to be able to specify which value you are modifying at runtime
you can do this too using reflection. use GetType on your object, and call
GetField with the parsed name, then SetValue. You will need to wrap in a try
catch block in case you specify a field name "x" which doesn't exist.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

"Freddyboy" <(E-Mail Removed)> wrote in message
newsDE6FAFA-C670-4A31-9348-(E-Mail Removed)...
> Hi,
>
> I'd like to use System.Runtime.CompilerServices with the Compact framework
> because I want to execute code which is in a string like that :
>
> int i = 0;
> string action = "i = 2;";
> ????.Execute(action);
> Console.Writeline ("La valeur de i est: " + i);
>
> In the compact framwork, System.Runtime.CompilerServices is not supported.
>
> Somebody knows a solution ?
>
> Thanks.
>
> Best Regards.



 
Reply With Quote
 
=?Utf-8?B?RnJlZGR5Ym95?=
Guest
Posts: n/a
 
      1st Mar 2005
Thanks Peter. It's ok.
In fact, in my compagny, we develps a project which allows create forms
dynamics since a file xml, like xaml. the project is almost finished.

Another question : do you have a date for Smart device framework 1.3 ?

Thanks.

Best regards.

"Peter Foot [MVP]" wrote:

> How much flexibility do you need? if you just need to set the value from a
> string use:-
> string val = "2"; //perhaps this comes from a data file etc
>
> int i = 0;
>
> i = Integer.Parse(val);
>
> Console.Writeline ("La valeur de i est: " + i);
>
> If you have a finite number of operators you could write code in a switch
> block so depending on the contents of your string e.g. "+=", "=", "-=". If
> you also need to be able to specify which value you are modifying at runtime
> you can do this too using reflection. use GetType on your object, and call
> GetField with the parsed name, then SetValue. You will need to wrap in a try
> catch block in case you specify a field name "x" which doesn't exist.
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> www.inthehand.com | www.opennetcf.org
>
> "Freddyboy" <(E-Mail Removed)> wrote in message
> newsDE6FAFA-C670-4A31-9348-(E-Mail Removed)...
> > Hi,
> >
> > I'd like to use System.Runtime.CompilerServices with the Compact framework
> > because I want to execute code which is in a string like that :
> >
> > int i = 0;
> > string action = "i = 2;";
> > ????.Execute(action);
> > Console.Writeline ("La valeur de i est: " + i);
> >
> > In the compact framwork, System.Runtime.CompilerServices is not supported.
> >
> > Somebody knows a solution ?
> >
> > Thanks.
> >
> > Best Regards.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between CodeDOM and CompilerServices ? Aneesh Pulukkul [http://dotnet-revolutions.blogspo Microsoft C# .NET 1 21st Apr 2009 06:42 PM
Is CompilerServices.MethodImpl(MethodImplOptions.Synchronized) recommended? buu Microsoft Dot NET 1 20th Jul 2007 09:57 PM
VisualBasic.CompilerServices Error Chris Mullins [MVP] Microsoft Dot NET Compact Framework 0 19th Mar 2007 07:31 PM
'System.Runtime.CompilerServices.InternalsVisibleTo' Davis Microsoft Dot NET Compact Framework 1 30th Jun 2006 03:40 PM
Bug in Microsoft.VisualBasic.CompilerServices.Utils.MethodToString() method SR Microsoft Dot NET 0 13th Aug 2003 04:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.