Roslyn, passing values through hostObject

前提是你 提交于 2019-12-04 10:05:11

The error message is exactly right. When you have a host object, you can't access it by the name of the local variable that holds it in your method (how would that even work? how would ScriptEngine learn that name?).

Instead, you can access the host object directly, almost as if you were writing a member method of that type (but not quite, you can't use this or access non-public members).

This means that you should write just:

session.Execute("destination")

BTW, according to .Net naming guidelines, names of public properties should start with upper case letter (e.g. Destination).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!