未设置什么对象引用?

时间:2019-07-16 09:32:00

标签: c# r.net

  

注意:这不是重复项。这与中的空引用无关   一般而言,它特定于R.Net

我正在使用r.net 1.7版

为什么会出现此null ref错误?我来自:

https://github.com/rdotnet/rdotnet/blob/master/TestApps/SimpleTest/Program.cs

   public static void Go()
    {
        string rHome = null;
        string rPath = null;

    NativeUtility util = new NativeUtility();
    Console.WriteLine(util.FindRPaths(ref rPath, ref rHome));


    REngine.SetEnvironmentVariables(rPath: rPath, rHome: rHome);
    using (REngine engine = REngine.GetInstance())
    {

    }
  

REngine.GetInstance引发此错误:

System.NullReferenceException未处理   HResult = -2147467261   Message =对象引用未设置为对象的实例。   来源= RDotNet   堆栈跟踪:        在RDotNet.SymbolicExpression..ctor(REngine引擎,IntPtr指针)        在RDotNet.ExpressionVector.GetValue(Int32索引)        在RDotNet.ExpressionVector.get_Item(Int32索引)        在RDotNet.Vector 1.<GetEnumerator>d__22.MoveNext() at System.Linq.Enumerable.First[TSource](IEnumerable 1个源中)        在RDotNet.REngine.Parse(String语句,StringBuilder incompleteStatement)        在RDotNet.REngine.d__46.MoveNext()        在System.Linq.Enumerable.LastOrDefault [TSource](IEnumerable`1源)处        在RDotNet.REngine.Evaluate(String语句)        在RDotNet.REngine.Initialize(StartupParameter参数,ICharacterDevice设备,布尔值setupMainLoop)        在RDotNet.REngine.GetInstance(字符串dll,布尔值初始化,StartupParameter参数,ICharacterDevice设备)        在H:\ Projects \ GeneralTests \ GeneralTests \ RTest.cs:line 23的GeneralTests.RTest.Go()中        在H:\ Projects \ GeneralTests \ GeneralTests \ Form1.cs:line 57中的GeneralTests.Form1.button7_Click(Object sender,EventArgs e)中        在System.Windows.Forms.Control.OnClick(EventArgs e)        在System.Windows.Forms.Button.OnClick(EventArgs e)        在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)        在System.Windows.Forms.Control.WmMouseUp上(消息和m,MouseButtons按钮,Int32单击)        在System.Windows.Forms.Control.WndProc(Message&m)        在System.Windows.Forms.ButtonBase.WndProc(Message&m)        在System.Windows.Forms.Button.WndProc(Message&m)        在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)        在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&msg)        在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32原因,Int32 pvLoopData)        在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32原因,ApplicationContext上下文)        在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32原因,ApplicationContext上下文)        在H:\ Projects \ GeneralTests \ GeneralTests \ Program.cs:line 19中的GeneralTests.Program.Main()        在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String []参数)        在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)中        在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()        在System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型saveSyncCtx)        在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔类型saveSyncCtx)        在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)        在System.Threading.ThreadHelper.ThreadStart()   InnerException:

0 个答案:

没有答案