xsharp.eu • X# Scripting question - Page 2
Page 2 of 2

X# Scripting question

Posted: Tue Jul 18, 2017 2:03 pm
by wriedmann
Hi Chris,

thank you very much!

When you are ready, I'll need to find an alternative way to the .config file as I have to implement this functionality in a DLL library (that is loaded dynamically at runtime).

Wolfgang

X# Scripting question

Posted: Wed Jul 19, 2017 5:59 am
by wriedmann
Hi,

if someone is interested: Chris has sent me yesterday an old version of the scripting DLLs, and they work now.

This is the code:

Code: Select all

method Process( cScriptCode as string ) as string 
local cReturn as string
local oReturn as object
	
cReturn := "" 
try                   
		
oReturn := XSharpScript.EvaluateAsync( ;
    cScriptCode, ScriptOptions.Default, _oParameters ):Result
cReturn	:= oReturn:ToString()
		
catch oEx as Exception
		
MessageBox.Show( _oOwner, oEx:Message, "Script error" )
		
end try
	
return cReturn
and I had to add a .config file with the following content:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.2.1.0" newVersion="1.2.1.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
and a few DLLs more:

System.Collections.Immutable.dll
System.IO.FileSystem.dll
System.Reflection.Metadata.dll
System.Security.Cryptography.Algorithms.dll
System.Security.Cryptography.Primitives.dll
System.Text.Encoding.CodePages.dll
System.ValueTuple.dll
System.Xml.ReaderWriter.dll
XSharp.CodeAnalysis.dll
XSharp.CodeAnalysis.dll.config
XSharp.Scripting.dll

Wolfgang

X# Scripting question

Posted: Wed Jul 19, 2017 7:52 am
by wriedmann
To complete my message: attached to this message you will find a zip archive with the application source as XIDE export file and the needed DLLs.

Wolfgang

X# Scripting question

Posted: Thu Jul 20, 2017 8:51 am
by robert
Wolfgang,

Would it help if we build the scripting DLL against the .Net Framework in stead of .Net Standard, so you it depends on less assemblies?

Robert

X# Scripting question

Posted: Thu Jul 20, 2017 10:20 am
by wriedmann
Hi Robert,

yes, that would definitely help. Since .NET Standard has no GUI, there is no possibility to build GUI applications against .NET Standard.

For web server applications it would be better to have .NET Standard. Maybe you could deliver both versions?

Thank you for asking!

Wolfgang