DynamicMethod (JIT Compiler encountered an internal limitation. )我還是相信中國人

來源:互聯網
上載者:User

錯誤在微軟社區,沒人解決,看來洋鬼子還是不咋地,沒CNBLOGS人熱心^_^

首先看異常提示:

JIT Compiler encountered an internal limitation.

 

程式碼:

在運行委託的時候,就異常了。

 

代碼

private decimal ProductKPIdata(Type type,string methodName,Guid userId,int year)
        {
            var cache = HttpRuntime.Cache;
            if (cache[methodName] != null)
                return ((Func<Guid, int, decimal>)cache[methodName])(userId,year);

            var dynamicMethod = new DynamicMethod("Gan",typeof(decimal), new Type[] { typeof(Guid), typeof(int) },typeof(AnalyzeResultBLL).Module);
            var ilGen = dynamicMethod.GetILGenerator();//IL產生器
            //把參數推到堆棧上
            ilGen.Emit(OpCodes.Ldarg_0);
            ilGen.Emit(OpCodes.Ldarg_1);
            ilGen.Emit(OpCodes.Ldarg_2);
            ilGen.Emit(OpCodes.Call, type.GetMethod(methodName, new Type[] { typeof(Guid), typeof(int) }));
            ilGen.Emit(OpCodes.Ret);//結束並傳回值

            //產生委託
            Func<Guid, int, decimal> gan = 
                (Func<Guid, int, decimal>)dynamicMethod.CreateDelegate(typeof(Func<Guid, int, decimal>));
            //委託放入緩衝
            cache.Insert(methodName,gan);

            //調用委託返回結果
            return gan(userId,year);
        }

 

 

 

至於為什麼搞這麼個垃圾方法,也是特殊原因,搞累了,都說不來了,只是貼出錯誤的地方,本著問題的核心,所以

如果有說參數、方法啊其他的問題就免了,核心問題是異常。許可權?到底這麼解決?

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.