Method not found: 'System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)'.

946 views
Skip to first unread message

rmb...@gmail.com

unread,
Dec 17, 2012, 1:30:43 PM12/17/12
to cs-s...@googlegroups.com
Hi,
When i try to execute any script i get that error.

I tried to execute the Host Sample, but it fails with any Sample.
I'm using windows 7 x64, with VS 2010 and Latest Version o CSScript : build v0.1.1779.37312


What i'm i doing wrong?


Server stack trace:
   at CSScriptLibrary.FastInvoker.GenerateMethodInvoker(MethodInfo methodInfo)
   at CSScriptLibrary.FastInvoker..ctor(MethodInfo info)
   at CSScriptLibrary.AsmBrowser.Invoke(Object obj, String methodName, Object[] list)
   at CSScriptLibrary.AsmBrowser.Invoke(String methodName, Object[] list)
   at CSScriptLibrary.AsmRemoteBrowser.Invoke(String methodName, Object[] list)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at CSScriptLibrary.IAsmBrowser.Invoke(String methodName, Object[] list)
   at CSScriptLibrary.AsmHelper.Invoke(String methodName, Object[] list)
   at Host.ExecuteAndUnloadScript(String script) in C:\Trabalhos\SmartDocumentor\Utils\CSScriptingLibrary\cs-script\Samples\Hosting\VS2010 project\Host.cs:line 50
   at Host.Start() in C:\Trabalhos\SmartDocumentor\Utils\CSScriptingLibrary\cs-script\Samples\Hosting\VS2010 project\Host.cs:line 37
   at Host.Main() in C:\Trabalhos\SmartDocumentor\Utils\CSScriptingLibrary\cs-script\Samples\Hosting\VS2010 project\Host.cs:line 59

Oleg Shilo

unread,
Dec 17, 2012, 10:20:23 PM12/17/12
to cs-s...@googlegroups.com
I am not sure you are using the latest version as it is (3.4.0.0 not 0.1.1779...).

Please check the sample I prepared for you: https://dl.dropbox.com/u/2192462/rmbsps/HostingSimplified.7z

Please execute the "RunAsScript.cmd" from the sample and let me know the outcome. If there is indeed some packaging/downloading problem I'd like to know it. 

Thanks,
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com
Message has been deleted
Message has been deleted

rmb...@gmail.com

unread,
Dec 18, 2012, 9:03:34 AM12/18/12
to cs-s...@googlegroups.com, rmb...@gmail.com
Hi Oleg,
Thank you for the reply.
I think there is some problema with the latest version.
This time i tried with a diferente Computer running Windows 8, 32 bits, and VS2012 and i get the same result:
 
C:\temp\HostingSimplified>css host
C# Script execution engine. Version 3.4.0.0.
Copyright (C) 2004-2012 Oleg Shilo.
Error: Specified file could not be executed.
System.ApplicationException: Method *.Execute(Host) cannot be found.
   at CSScriptLibrary.AsmBrowser.FindMethod(String methodName, Type[] args)
   at CSScriptLibrary.AsmBrowser.FindMethod(String methodName, Object[] list)

   at CSScriptLibrary.AsmBrowser.Invoke(Object obj, String methodName, Object[]
list)
   at CSScriptLibrary.AsmBrowser.Invoke(String methodName, Object[] list)
   at CSScriptLibrary.AsmHelper.Invoke(String methodName, Object[] list)
   at Host.ExecuteScript(String script)
   at Host.Start()
   at Host.Main()
 
BUT if i use the older version 3.2.0.0 it works as you can see here:
 
C:\temp\HostingSimplified\cs-script3.2\cs-script\Lib\Bin\NET 4.0>css host
C# Script execution engine. Version 3.2.0.0.
Copyright (C) 2004-2011 Oleg Shilo.
Script: working with Host
Host: creating document...
Host: closing document...
Host: opening document (document.txt)...
Host: saving document (document1.txt)...

Oleg Shilo

unread,
Dec 18, 2012, 6:43:07 PM12/18/12
to cs-s...@googlegroups.com
Hi there,

I cannot reproduce the problem on the fresh Win8 x64 (x64 should not make any difference) installation with the fresh CS-Script v3.4.0 copy from Web. Is it possible that you modify by accident the script.cs file?

Anyway, to troubleshoot it further please zip and send my the whole directory you are working with (e.g. <cs-script>\Samples\Hosting\HostingSimplified). Please attach the whole cache folder too. To access the cache folder right click the script file and select CS-Script->Advanced->Open cache directory

Inline image 1

Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com



image.png

ro...@codeshrink.com

unread,
Dec 31, 2012, 3:11:34 AM12/31/12
to cs-s...@googlegroups.com, rmb...@gmail.com
Ditto here.

3.4.0 Gave me the same problem.

3.2.0 Seems to be working fine

leicht...@gmail.com

unread,
Jan 10, 2013, 4:59:39 AM1/10/13
to cs-s...@googlegroups.com, osh...@gmail.com
Hi,

I have the same problem on a .NET 4.0 project.
If I use the .NET 3.5 DLL it works ok.
If I use the .NET 4.0 DLL I get the error; the CreateDelegate method is only available from .NET 4.5.
So it seems to me the 4.0 DLL is mistakenly compiled for 4.5.
I couldn't check against an old version because I could not find the downloads any more.

So the workaround is to use the 3.5 DLL, but if possible, please correct this.

Regards, Leo

Oleg Shilo

unread,
Jan 14, 2013, 8:42:00 PM1/14/13
to cs-s...@googlegroups.com
Hi all,
 
Sorry I am recovering after the surgery and cannot be very helpful. 
 
It seems like indeed CreateDelegate needs to be take more care off. I will have a look at what needs to be done  when I am back.
 
Please keep in mind that the CS-Script is as product is targeting the latest .NET release (v4.5) however the script engine builds for early CLRs can be found in the <cs-script>\Lib\Bin
Regards,
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com


Oleg Shilo

unread,
Jan 19, 2013, 11:15:24 PM1/19/13
to cs-s...@googlegroups.com
Hi all,

OK, the problem is solved and the latest release (v3.4.2 http://csscript.net/CurrentRelease.html) has the issue addressed.

The issue was quite interesting...

Despite CS-Script being compiled against the latest .NET version (v4.5) it is expected to run on v.4.5 as well because it uses none of the v4.5 specific features and both .NET v4.0 and v4.5 use the same CLR.

However in .NET v4.5 MS has break the implementation of DynamicMethod.CreatDelegate (method present in both v4.0 and v4.5) by moving its actual implementation to the base type MethodInfo.CreatDelegate.   

This makes it impossible to use the CS-Script full suite on .NET v4.0 but only on .NET v4.5. (Note: the script engine hosting is not affected by this constrain)

Despite this compatibility constrain being always the case with all major .NET updates I feel that it would be too much inconvenience for the CS-Script users to request them migrating on .NET v4.5. Thus the latest CS-Script release v3.4.2 supports so called "re-targeting".  
 
On the first run of css-config.exe, if .NET v4.0 is detected but v4.5 is not, user will be prompted to confirm automatic internal replacement (patching) of the CSScriptLibrary.dll assembly with its v4.0 compiled equivalent. Once replacement is done the CS-Script suite can be run on .NET v4.0 without any restrictions. 

Note you can always access CS-Script binaries compiled for various CLR versions here in the <cs-script>\Lib\Bin folder:


Inline image 1


Regards,
Oleg Shilo
--------------------------------------------------------------------------------------------
Internet: http://www.csscript.net
E-Mail: csscript...@gmail.com


image.png
Reply all
Reply to author
Forward
0 new messages