zoukankan      html  css  js  c++  java
  • 执行用户定义例程或聚合 "" 期间出现 .NET Framework 错误:

    消息 6522,级别 16,状态 1,过程 InsertCurrency_String,第 0 行
    在执行用户定义例程或聚合 "InsertCurrency_String" 期间出现 .NET Framework 错误:
    System.NullReferenceException: 未将对象引用设置到对象的实例。
    System.NullReferenceException:
       在 SqlServerCLRCallNet.GetConfigApp..ctor()
       在 SqlServerCLRCallNet.CLRFunction.CallSAPFunUpdateDataVB(String strFunName, ListDictionary strArgs, ListDictionary strTableArgs, ListDictionary strRetTabs, ListDictionary& strResult)
       在 SqlServerCLRCallNet.CLRFunction.GetResultSetString(String SNO, String strSONum, String strLot, String strSchedLine, DateTime DTUpdateData)

    System.NullReferenceException: 未将对象引用设置到对象的实例。

     

    原因:代码里面无法读取到Config里面的数据

    LFCFunction.cs

     GetConfigApp getApp = new GetConfigApp();
                try
                {
                    VBSAP VBSap = new VBSAP(null, getApp.ApplicationServer, getApp.Client, getApp.SystemNumber.ToString());
                    bool boolConn = VBSap.ConnectToSAP(getApp.User, getApp.Password, getApp.Language);

     

    GetConfigApp.cs

    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"]); 


        }
    }

    App.config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <appSettings>
            <!-- SAP系统IP -->
            <!-- SAP系统IP -->
            <add key="ApplicationServer" value="192.168.00.00" />

            <!-- SAP客户端号500 -->
            <add key="Client" value="500"/>
            <!-- SAP登陆语言 -->
            <add key="Language" value="ZH"/>
            <!-- 用户帐号 -->
            <add key="User" value="ZRFC_USER"/>
            <!-- 用户密码 -->
            <add key="Password" value="erp.rfc"/>
            <!-- SAP系统编号 -->
            <add key="SystemNumber" value="20" />
            <add key="ClientSettingsProvider.ServiceUri" value="" />
        </appSettings>
        </configuration>
  • 相关阅读:
    Java基础---Java 开发工具IntelliJ IDEA 安装
    Java基础---Java循环区别
    Java基础---JavaJShell脚本工具
    Java基础---Java方法
    Java基础---Java三元运算
    Java基础---Java变量
    Java基础---Java数据类型
    Java基础---Java常量
    “ERROR: Cannot read property 'fileCoverage' of undefined...”
    矩阵乘积
  • 原文地址:https://www.cnblogs.com/Snowfun/p/2683282.html
Copyright © 2011-2022 走看看