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;
            }
        }
    }
  • 相关阅读:
    radio按钮组和label标签
    div布局
    bootstrap模态框使用
    bootstrap按钮组下拉菜单使用
    Bootstrap下拉菜单和导航栏的使用
    Bootstrap源码解读下拉菜单
    python中django学习2
    windows下配置桌面github
    状态模式--无尽加班何时休
    直接在安装了redis的Linux机器上操作redis数据存储类型--set类型
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2681509.html
Copyright © 2011-2022 走看看