1

wcfでサービスを作成します

public interface IScriptService
{
    [OperationContract]
    string ExecuteScript(string code);

    [OperationContract]
    string GetString(string code); // Method for test service
}

public class ScriptService : IScriptService
{
    public string ExecuteScript(string code)
    {
        var a = CSharpScript.Create(code);
        var b = a.RunAsync();
    }
}

コードを実行しようとすると、アセンブリ System.Reflection.Metadata、Version=1.2.0.0 を読み込めないという例外がスローされます。サービスなしでCSharpScriptを実行すると、例外は発生しません。スクリプトはうまく機能します

    Server stack trace: 
       в System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       в System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       в System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       в System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       в System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       в Host.IScriptService.ExecuteScript(String code)
       в Host.ScriptHost.Execute(String code) в C:\Users\Ivan\Documents\Visual Studio 2015\Projects\LinqPad\Host\ScriptHost.cs:строка 50
       в LinqPad.MainWindow.button_Click(Object sender, RoutedEventArgs e) в C:\Users\Ivan\Documents\Visual Studio 2015\Projects\LinqPad\LinqPad\MainWindow.xaml.cs:строка 37
       в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       в System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       в System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
       в System.Windows.Controls.Primitives.ButtonBase.OnClick()
       в System.Windows.Controls.Button.OnClick()
       в System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       в System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
       в System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       в System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       в System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       в System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
       в System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       в System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       в System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       в System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       в System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       в System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       в System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       в System.Windows.Input.InputManager.ProcessStagingArea()
       в System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       в System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       в System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       в System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       в System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       в MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       в System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       в MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       в System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       в System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       в System.Windows.Application.RunDispatcher(Object ignore)
       в System.Windows.Application.RunInternal(Window window)
       в System.Windows.Application.Run(Window window)
       в System.Windows.Application.Run()
       в LinqPad.App.Main()
       в System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       в System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       в System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       в System.Threading.ThreadHelper.ThreadStart()


in packages:
Microsoft.CodeAnalysis version 1.3.2
Microsoft.CodeAnalysis.CSharp.Script version 1.3.2
Sustem.ServiceModel version 4.0.0
4

0 に答える 0