提示错误:
由于 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;
}
}
}
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"]);
}
}
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;
}
}
}
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;
}
}
}