2012-12-18 2 views
1

상황 : 윈도우 7, ExcelDNA 0.30, 난 여전히 ExcelDNA를 통해 Excel에서 작업 PARAMS/ParamArray 접근 방식을 얻으려고 .NET 4.0IL은 varags 및 ExcelDNA

. varags를 사용하여 System.ParamArrayAttribute와 System.ArgIterator로 경로를 추구하는 것을 피합니다.

슬픈 사실은 다음과 같이 컴파일되지만 여전히 작동하지 않는다는 것입니다. 나는 가치 오류를 계속 지니고있다. 뭔가 어리 석으나이 어셈블러를 알기에는 아직 알지 못합니다. 어떤 아이디어, 누구?

.assembly extern mscorlib { } 
.assembly Test {} 
.module test.dll 
.namespace VTest { 
    .class public Test { 
     // Compute sum of undefined number of arguments 
     .method public static vararg int64 IntSum(/* all arguments optional */) 
     { 
      .locals init(valuetype [mscorlib]System.ArgIterator Args, 
         unsigned int64 Sum, 
         int32 NumArgs) 
      ldc.i8 0 
      stloc Sum  


      ldloca Args 
      arglist // Create argument list structure 
      // Initialize ArgIterator with this structure: 
      call instance void [mscorlib]System.ArgIterator::.ctor( 
       value class [mscorlib]System.RuntimeArgumentHandle) 

      // Get the optional argument count: 
      ldloca Args 
      call instance int32 [mscorlib]System.ArgIterator::GetRemainingCount() 
      stloc NumArgs 

      // Main cycle: 
      LOOP: 
      ldloc NumArgs 
      brfalse RETURN // if(NumArgs == 0) goto RETURN; 

      // Get next argument: 
      ldloca Args 
      call instance typedref [mscorlib]System.ArgIterator::GetNextArg() 

      // Interpret it as unsigned int64: 
      refanyval [mscorlib]System.UInt64 
      ldind.u8 

      // Add it to Sum: 
      ldloc Sum 
      add 
      stloc Sum // Sum += *((int64*)&next_arg) 

      // Decrease NumArgs and go for next argument: 
      ldloc NumArgs 
      ldc.i4.m1 
      add 
      stloc NumArgs 
      br LOOP 

      RETURN: 
      ldloc Sum 
      ret 
     } 

    } 
} 
+1

"계속 가치 오류가 발생합니다."어떤 종류의 오류가 있습니까? 어디서 가져 오는거야? 또한, 왜 당신은'varagrs'와 일리노이를 처음부터 사용하려고합니까? – svick

+1

나는 C#에서 (__arglist를 사용하여) 당신의 메소드를 호출 해 보았는데 제대로 동작했다. 그래서 문제는 아마도 ExcelDNA 또는 여러분이 사용하는 방식 일 것입니다. – svick

+0

@svick : 적어도 그것이 작동한다는 것을 증명해 주셔서 감사합니다. 슬프게도 Govert가 "Answer"에서 말한 것처럼 ExcelDNA는 params/ParamArray를 지원하지 않습니다. – bugmagnet

답변

3

Excel-DNA (그리고 엑셀 C의 API)는 현재 지원하지 않습니다 (버전 0.30)을 '의 PARAMS'선택적 매개 변수. 자세한 내용 및 가능한 해결 방법은이 토론을 참조하십시오. http://exceldna.codeplex.com/discussions/406719

+0

Excel-DNA CustomRegistration 프로젝트 (https://github.com/Excel-DNA/CustomRegistration)는 이제 '매개 변수'매개 변수 배열을 지원합니다. – Govert