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;
            }
        }
    }
  • 相关阅读:
    java制作的applet小型播放器
    java文件路径问题及Eclipse package,source folder,folder区别及相互转换
    转:文件操作之File类使用
    JFrame setDefaultLookAndFeelDecorated(true)
    java错误Cannot make a static reference to the nonstatic method
    转:HTML操作 Swing Components
    组件服务简介
    计算ttest 的C程序
    Excel统计函数中比较常用的函数
    Correlation with pvalues
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2681509.html
Copyright © 2011-2022 走看看