Closed X39 closed 3 years ago
yes it is possible.
Try to use CSScript.CodeDomEvaluator
it allows using namespaces.
The problem with Roslyn compiler is that it takes the script code and treats it as a class declaration. Whereas CodeDom treats it as a C# file.
Solved it already by pretty much updated all script files. Was substantially less work then i expected at first, thanks to some basic regex magic i did.
Thanks anyways :)
Summary
Hello there, i am currently migrating from .net framework to .net core and am facing issues during this process.
Prior i used
CSScriptLibrary.CSScript.LoadCode
to load a file as a whole and get the assembly returned, receiving the method later using a "default" method name.The benefit has been that i had more control about what the methods can access easily, thanks to additional
using
instructions, and could place the code into a certain namespace, easing the navigation further.The issue i now face is that this approach presents me with a
You cannot declare namespace in script code
error message.The relevant code in question is as follows:
.Net Framework code
.Net Core code
The outer shell for
code
is the follows:Is it possible to get the same behavior?
Thanks for your time, X39