zoukankan      html  css  js  c++  java
  • CREATE ASSEMBLY 失败 safe 程序集中不允许存储到静态字段

    提示错误:

    由于 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;
            }
        }
    }
  • 相关阅读:
    书单
    parzen 窗的matlab实现
    Oracle-07
    图片加载不出来
    省市区三表建立及数据插入
    a链接与button按钮混用
    省市区三级联动,获取地区编号,JSON格式
    纯JS省市区三级联动
    JDK与JRE的区别
    web-03-jQuery
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2681509.html
Copyright © 2011-2022 走看看