简体   繁体   中英

Moving project from Visual Studio 2005 to 2012 - System.ArgumentNullException, multiple errors

I am currently trying to move an existing project from VS 2005 to VS 2012. The project is written in C# and contains some even older code in C++ which is used as the core for some specific scientific calculations. Those parts are connected by a wrapping layer in C++.

I opened the existing main project in VS 2012 and let it do it's thing importing the older project files. Then I tried compiling each project one-by-one. I replaced some older libraries (eg boost) and am now stuck.

I am getting this error which I cannot solve because VS will not tell me at which line the error occurs. I tried Resharper but it does not seem to find an error in this particular project (although I'm using Resharper for the first time and it finds hundreds of errors and warnings all over the other projects).

1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: The "NativeCodeAnalysis" task failed unexpectedly.
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: Microsoft.VisualStudio.CodeAnalysis.AnalysisResults.AnalysisResultException:       CA0001 : An unknown error occurred while running Code Analysis. ---> System.ArgumentNullException: Value cannot be null.
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018: Parameter name: path2
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at System.IO.Path.Combine(String path1, String path2)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at Microsoft.Build.Tasks.TaskCommon.GetRuleSetFullPath(String ruleSet, String projectDirectory, String[] ruleSetDirectories)
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at Microsoft.Build.Tasks.NativeCodeAnalysis.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    --- End of inner exception stack trace ---
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at Microsoft.Build.Tasks.NativeCodeAnalysis.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(342,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()


I spent hours trying to find a solution to my problem. So if my question is badly asked - please try to help nonetheless and tell me what information is needed.

This is the code of the project's .cpp-file:

namespace Trace 
{
  CTraceWrapper::CTraceWrapper(const char *LibName) : CBaseWrapper(LibName), m_GetTraceTextProc(NULL)
  {
    if (m_hModInstance != NULL)
    {
      m_GetTraceTextProc = (tGetTraceText)GetProcAddress(m_hModInstance, "getTraceText");
    }
  }
  int CTraceWrapper::getTraceText(t_TraceTextMap& traceTextMap, bool bDelete)
  {
#ifdef _TRACE_ACTIVE
    if (m_GetTraceTextProc == NULL)
    {
      return RESULT_ERR_INVALID_FUNCTION_HANDLE;
    }
    m_GetTraceTextProc(traceTextMap, bDelete);
#endif

    return RESULT_OK;
  }

  CTraceWrapper Wrapper("trace.dll");

  int TraceWrapper::GetTraceList(array<TraceData^> ^%traceMap, bool bDelete)
  {
    t_TraceTextMap traceTextMap;

    int nRet = Wrapper.getTraceText(traceTextMap, bDelete);

    if (nRet != 0)
    {
      return nRet;
    }

    TraceData^ Data;

    String^ Tmp;

    array<String^> ^Split;

    int Length = 0;

    if (nRet == RESULT_OK)
    {
      traceMap = gcnew array<TraceData^>(traceTextMap.size());

      int i = 0;

      for (t_TraceTextMap::const_iterator cit = traceTextMap.begin(); cit != traceTextMap.end(); cit++)
      {
        Data = gcnew TraceData();

        Data->Time = cit->first;

        Tmp = gcnew String(cit->second.chars());

        Split = Tmp->Trim()->Split('|');

        Data->Type = Convert::ToInt16(Split[0], CultureInfo::CurrentCulture);

        Data->Module = Convert::ToInt16(Split[1], CultureInfo::CurrentCulture);

        Data->ProcessId = Convert::ToInt32(Split[2], CultureInfo::CurrentCulture);

        Data->ThreadId = Convert::ToInt32(Split[3], CultureInfo::CurrentCulture);

        Length = Split->GetLength(0);

        Data->FunctionName = ((Length > 5) ? Split[5] : String::Empty);

        Data->FileName = ((Length > 4) ? Split[4] : String::Empty);

        Data->Line = ((Length > 6) ? Convert::ToInt32(Split[6], CultureInfo::CurrentCulture) : 0);

        Data->Text = ((Length > 7) ? Split[7] : String::Empty);

        if ((Data->Type == TRACE_TYPE_TIMING_END) && (Length > 8))
        {
          Data->Interval = Convert::ToDouble(Split[8], CultureInfo::InvariantCulture);
        }

        traceMap[i++] = Data;
      }
    }

    return RESULT_OK;
  }
}

Try opening the csproj file for the project that's failing and examine that. In VS2015 csproj files are msbuild files. Thats one option I can think of, the other is to try turn off code analysis.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM