CREATE ASSEMBLY 失敗 safe 程式集中不允許儲存到靜態欄位

來源:互聯網
上載者:User

提示錯誤:

由於 safe 程式集 'SqlServerCLRCallNet' 中 'SqlServerCLRCallNet.TEST' 類型的方法 'CallSAPFunUpdateDataVB' 將儲存到靜態欄位,CREATE ASSEMBLY 失敗。
在 safe 程式集中不允許儲存到靜態欄位

 

過程代碼:

View Code

using System;
using System.Collections.Generic;
using System.Text;
using VBLib;

namespace SqlServerCLRCallNet
{
    public class TEST
    {
        private static string ApplicationServer = System.Configuration.ConfigurationManager.AppSettings["ApplicationServer"].ToString();
        private static string Client = System.Configuration.ConfigurationManager.AppSettings["Client"].ToString();
        private static string SystemNumber = System.Configuration.ConfigurationManager.AppSettings["SystemNumber"].ToString();

        public static DataSet CallSAPFunUpdateDataVB(string strFunName, ListDictionary strArgs, ListDictionary strTableArgs, ListDictionary strRetTabs, ref ListDictionary strResult)
        {
            VBSAP VBSap = new VBSAP(null, ApplicationServer, Client, SystemNumber.ToString());
            return null;
        }
    }
}

 

在SQL 中執行語句:提示以上錯誤

create assembly asmSqlServerCLRCallNet from'c:\SqlServerCLRCallNet.dll'

 

修改後:

View Code

using System;
using System.Collections.Generic;
using System.Text;

namespace SqlServerCLRCallNet
{
    public class GetConfigApp
    {
        public  string ApplicationServer = System.Configuration.ConfigurationManager.AppSettings["ApplicationServer"].ToString();
        public  string Client =  System.Configuration.ConfigurationManager.AppSettings["Client"].ToString();
        public  string Language =  System.Configuration.ConfigurationManager.AppSettings["Language"].ToString();
        public  string User =  System.Configuration.ConfigurationManager.AppSettings["User"].ToString(); 
        public  string Password = System.Configuration.ConfigurationManager.AppSettings["Password"].ToString(); 
        public  int SystemNumber =  int.Parse(System.Configuration.ConfigurationManager.AppSettings["SystemNumber"]); 

    }
}

View Code

using System;
using System.Collections.Generic;
using System.Text;
using VBLib;

namespace SqlServerCLRCallNet
{
    public class TEST
    {
        

        public static DataSet CallSAPFunUpdateDataVB(string strFunName, ListDictionary strArgs, ListDictionary strTableArgs, ListDictionary strRetTabs, ref ListDictionary strResult)
        {
            GetConfigApp getConfig = new GetConfigApp();

            VBSAP VBSap = new VBSAP(null, getConfig.ApplicationServer, getConfig.Client, getConfig.SystemNumber);
            return null;
        }
    }
}

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.