How do I code this?

General discussions related to using the C# Script Engine in APL+Win.

Moderators: Tech Support, phpbb_admin

How do I code this?

Postby Ajay Askoolum » September 19th, 2014, 4:24 pm

I do not have a clue about getting CSE to understand the line shown in bold below; any hints?

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Reflection;
using System.Runtime.CompilerServices;

using System.Management;

[assembly: AllowPartiallyTrustedCallers]

namespace WinMgmt
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: How do I code this?

Postby joe_blaze » October 8th, 2014, 1:34 am

Hi Ajay,

You are asking how can you direct the CSE to execute compiler instructions like [assembly: AllowPartiallyTrustedCallers].
This is an assembly attributes and is not a separately-executable C# statement.
This assembly attribute is actually a compiler directive that will only be acted upon when the C# source code for an assembly is compiled by the Microsoft JIT compiler.

The CSE is designed to provide the APL+Win programmer the ability to execute C# executable statements.
The CSE is effectively a line-by-line C# statement interpreter based on the Microsoft Roslyn technology.

When the CSE 'Init' method is used the C# side of the CSE creates an in-memory assembly.
The APL+Win/CSE programmer cannot modify the attributes of that in-memory assembly.

When assembly or module attributes are needed, I suggest that you use Visual Studio to create your assembly, build it, giving it a 'strong' name if you are using the AllowPartiallyTrustedCallers assembly attribute, and then use the CSE 'LoadAssembly' method to load the assembly into the context of a CSE instance.

Joe Blaze
joe_blaze
 
Posts: 384
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361

Re: How do I code this?

Postby Ajay Askoolum » October 30th, 2014, 4:40 pm

Thanks Joe.

I think I understand why []cse cannot abide compiler instructions. However, it appears to understand some attributes
when you exec a block of code e.g.

[ComImport()]

Could you verify and confirm, please?
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: How do I code this?

Postby joe_blaze » October 30th, 2014, 5:39 pm

Hi Ajay,

To speed up my research into this question, please provide me with a code example which runs in Visual Studio. I will test that and try to 'translate' that to a CSE script.

Joe
joe_blaze
 
Posts: 384
Joined: February 11th, 2007, 3:09 am
Location: Box 361 Brielle, NJ 08730-0361


Return to APL+Win & The C# Script Engine

Who is online

Users browsing this forum: No registered users and 3 guests

cron