0

我正在使用在此处找到的 R.NET dll: http ://rdotnet.codeplex.com/ 我正在尝试从为 Tradelink 指定的自定义 C# DLL (http://code.google.com/p/) 中运行示例代码贸易通)这是代码。

   using System;
   using System.IO;
   using System.Linq;
   using RDotNet;
   using TradeLink.Common;
   using TradeLink.API;
   using Microsoft.Win32;

namespace Responses
{
    class RTLTest : ResponseTemplate
    {


        ////static void Main(string[] args)
        public override void GotTick(TradeLink.API.Tick k)
        {
             //Set the folder in which R.dll locates.
            REngine.SetDllDirectory(@"C:\Program Files\R\R-2.12.0\bin\i386");

            REngine.SetDllDirectory(GetRPath());
            REngine.SetDllDirectory(@"C:\Program Files\R\R-2.14.1\bin\i386");


            using (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" }))  // quiet mode
            {
                // .NET Framework array to R vector.
                NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
                engine.SetSymbol("group1", group1);
                // Direct parsing from R script.
                NumericVector group2 = engine.EagerEvaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric();

                // Test difference of mean and get the P-value.
                GenericVector testResult = engine.EagerEvaluate("t.test(group1, group2)").AsList();
                double p = testResult["p.value"].AsNumeric().First();

                string s1 = String.Format("Group1: [{0}]", string.Join(", ", group1));
                string s2 = String.Format("Group2: [{0}]", string.Join(", ", group2));
                string s3 = String.Format("P-value = {0:0.000}", p);

                senddebug(s1);
                senddebug(s2);
                senddebug(s3);
            }
        }
}

但我得到一个错误:

响应引发异常:无法加载文件或程序集“R.NET,版本=1.4.0.0,文化=中性,PublicKeyToken=null”或其依赖项之一。试图加载格式不正确的程序。

任何人都可以帮助解决这个问题吗?

4

1 回答 1

0

if your ASP.NET application is 64 bit, then this might be useful http://blogs.msdn.com/b/rakkimk/archive/2007/11/03/iis7-running-32-bit-and-64-bit-asp-net-versions-at-the-same-time-on-different-worker-processes.aspx. Most R packages dlls (except base package) are 32 bit, so it may be a source of the problem.

于 2013-01-02T19:19:42.997 回答