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;
            }
        }
    }
  • 相关阅读:
    git命令
    Java开发中的23种设计模式详解
    Linux下简单基本操作【备查】
    微信|公众平台开发者平台
    MyEclipse老是弹出problem occurred窗口
    spring 工具包怎么下载
    MyEclipse8.6启动后提示内存不足的解决方案(亲测,完美解决)
    bzoj2440,luoguP4318 完全平方数
    hdu5528
    CF1076E Vasya and a Tree
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2681509.html
Copyright © 2011-2022 走看看