1) DotNet_LoadCScode.au3 777 B

12345678910111213141516
  1. #include "..\..\Includes\DotNet.au3"
  2. Opt( "MustDeclareVars", 1 )
  3. Example()
  4. Func Example()
  5. ; Compiles C# source code on the fly
  6. ; Creates a .NET assembly DLL-file in memory
  7. ; Loads the memory assembly file into the default domain
  8. Local $oCode = DotNet_LoadCScode( FileRead( "ufbSoundDetect.cs" ), "System.Windows.Forms.dll" ) ; You must add the "System.Windows.Forms.dll"
  9. If @error Then Return ConsoleWrite( "DotNet_LoadCScode ERR" & @CRLF ) ; assembly because of line 1 in the C# code.
  10. ConsoleWrite( "DotNet_LoadCScode OK" & @CRLF )
  11. Local $oFoo = DotNet_CreateObject( $oCode, "Foo" ) ; $oFoo is an object of the "Foo" class in the C# code
  12. If IsObj( $oFoo ) Then $oFoo.Test() ; Test is a method (function) of the $oFoo object
  13. EndFunc