HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: jarrettv on September 24, 2014, 04:43:34 PM

Title: C# script need using statements?
Post by: jarrettv on September 24, 2014, 04:43:34 PM
(https://dl.dropboxusercontent.com/u/6142956/forums/Csharpupdateissue.png)

I'm running on a BBB debian with the mono-runtime from rasbian.
Title: Re: C# script need using statements?
Post by: bkenobi on September 24, 2014, 04:57:05 PM
I don't believe you can use "using" statements in C# scripts.  You can declare variables with the same code, though.  I'm a C# hacker (can only write based on code examples), so I couldn't show you what to do from scratch.
Title: Re: C# script need using statements?
Post by: Gene on September 24, 2014, 08:10:21 PM
Hi Ben,

this is fixed in next release. You can't use pragma like that. I placed them at the very beginning of the app wrapper (that cannot be modified from web editor).

g.
Title: Re: C# script need using statements?
Post by: Gene on September 24, 2014, 08:13:58 PM
Well, never mind it works =)
Anyway this will be default behaviour with next release, so no need to add pragma.

g.
Title: Re: C# script need using statements?
Post by: Gene on September 24, 2014, 08:20:59 PM
Hi jarrettv,

the problem is the way system libraries are referenced:

https://github.com/genielabs/HomeGenie/blob/master/HomeGenie/Automation/CSharpAppFactory.cs#L140

This "if" block decide how to load the libraries. Perhaps, for some reason, on BBB the variable "relocateSystemAsm" is not true.

g.

Title: Re: C# script need using statements?
Post by: jarrettv on October 09, 2014, 12:04:07 AM
Hi Gene, I was able to test this with a simple console application. Code is here:

https://gist.github.com/jarrettv/19ee88c0549f32dc8025

Here is the output on my BBB:

Code: [Select]
debian@arm:~$ sudo mono BbbAsmTest.exe
-----------------
/usr/local/lib/mono/4.5/mscorlib.dll
/home/debian/BbbAsmTest.exe
------------------Count=2
Testing linq: 3
-----------------
/usr/local/lib/mono/4.5/mscorlib.dll
/home/debian/BbbAsmTest.exe
/usr/local/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
------------------Count=3
Test compiling code
Mono.Runtime
3.4.1 (master/148b100 Sun Mar 30 09:59:44 UTC 2014)
Relocate:True
Compile=0,test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
-----------------
/usr/local/lib/mono/4.5/mscorlib.dll
/home/debian/BbbAsmTest.exe
/usr/local/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
/usr/local/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll

------------------Count=5

It shows the correct relocateSystemAsm value. I suppose the next step would be add some debug statements into HomeGenie.

Any other ideas?
Title: Re: C# script need using statements?
Post by: jarrettv on October 14, 2014, 08:00:15 PM
Gene, I submitted a pull request. I think your flag is backwards.