執行使用者定義常式或彙總 “” 期間出現 .NET Framework 錯誤:

來源:互聯網
上載者:User

訊息 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>

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.