the .net interop type cannot be used in code for the classic

iperutility
Member Posts: 18
Hello,
I had made a DLL in C#, easy, and put them under "C:\Program Files (x86)\Microsoft Dynamics NAV\60\Service\Add-ins".
The problem is :
1) I had declared a global variable DotNet of my DLL
2) I had Implemented the global variable
3) I had compiled my codeunit without error
but when I ran my codeunit, those got me this error : the .net interop type cannot be used in code for the classic.
C/AL code in form
sgatePXY := sgatePXY.SGATEProxy;
this is my DLL
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
namespace ClassLibrarySGATE
{
public class SGATEProxy
{
public X509Certificate certified;
public SgateWebService ProxySgate;
protected string Pass;
protected string User;
public tipoRispostaPresaInCaricoLotto result;
public tipoRichiestaPresaInCaricoLotto request;
public string requestXML;
public XmlDataDocument XDom;
public XmlNodeList xNodeList;
protected string idUltimoLottoRicevutoCorrettamente;
protected string NumeroMessaggi;
public SGATEProxy()
{
}
public bool CallSgateServer(string pathCertificati, string url, string username, string password)
{
ProxySgate = new SgateWebService();
XDom = new XmlDataDocument();
// Invio i certificati tramite il collegamento proxy web senza doverli registrare sul pc o server
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "SGATE.cer"));
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustPCA.cer"));
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustEV.cer"));
ProxySgate.ClientCertificates.Add(new X509Certificate(pathCertificati + username, password));
ProxySgate.Timeout = 360 * 1000;
return false;
}
public tipoRispostaPresaInCaricoLotto InvokePresaInCaricoLotto(tipoRichiestaPresaInCaricoLotto request, int tentativo)
{
result = null;
try
{
result = ProxySgate.PresaInCaricoLotto(request);
}
catch
{
if (tentativo < 5)
result = InvokePresaInCaricoLotto(request, tentativo + 1);
}
return result;
}
public string EsitoRichiestaLotto(tipoRichiestaPresaInCaricoLotto rispostaLotto)
{
if (string.IsNullOrEmpty(result.lottoMessaggi.idLotto))
return result.lottoMessaggi.idLotto;
else
return "KO";
}
public tipoRichiestaPresaInCaricoLotto GeneraRequestRichiestaLotto(string requestXML)
{
// Reding the request in XML format
XDom.Load(requestXML);
XmlNode xNodeMittente = XDom.SelectSingleNode("/Mittente");
foreach (XmlNode xNode in xNodeMittente)
{
User = xNode["login"].InnerText;
Pass = xNode["Password"].InnerText;
}
XmlNode xNodeRichiestaPresaInCaricoLotto = XDom.SelectSingleNode("/richiestaPresaInCaricoLotto");
foreach (XmlNode xNode in xNodeMittente)
{
idUltimoLottoRicevutoCorrettamente = xNode["idUltimoLottoRicevutoCorrettamente"].InnerText;
NumeroMessaggi = xNode["numeroMessaggi"].InnerText;
}
request = new tipoRichiestaPresaInCaricoLotto();
request.idUltimoLottoRicevutoCorrettamente = idUltimoLottoRicevutoCorrettamente;
request.mittente = new tipoMittente() { login = User, password = Pass };
request.numeroMessaggi = Convert.ToInt32(NumeroMessaggi);
return request;
}
}
}
I had made a DLL in C#, easy, and put them under "C:\Program Files (x86)\Microsoft Dynamics NAV\60\Service\Add-ins".
The problem is :
1) I had declared a global variable DotNet of my DLL
2) I had Implemented the global variable
3) I had compiled my codeunit without error
but when I ran my codeunit, those got me this error : the .net interop type cannot be used in code for the classic.
C/AL code in form
sgatePXY := sgatePXY.SGATEProxy;
this is my DLL
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
namespace ClassLibrarySGATE
{
public class SGATEProxy
{
public X509Certificate certified;
public SgateWebService ProxySgate;
protected string Pass;
protected string User;
public tipoRispostaPresaInCaricoLotto result;
public tipoRichiestaPresaInCaricoLotto request;
public string requestXML;
public XmlDataDocument XDom;
public XmlNodeList xNodeList;
protected string idUltimoLottoRicevutoCorrettamente;
protected string NumeroMessaggi;
public SGATEProxy()
{
}
public bool CallSgateServer(string pathCertificati, string url, string username, string password)
{
ProxySgate = new SgateWebService();
XDom = new XmlDataDocument();
// Invio i certificati tramite il collegamento proxy web senza doverli registrare sul pc o server
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "SGATE.cer"));
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustPCA.cer"));
ProxySgate.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustEV.cer"));
ProxySgate.ClientCertificates.Add(new X509Certificate(pathCertificati + username, password));
ProxySgate.Timeout = 360 * 1000;
return false;
}
public tipoRispostaPresaInCaricoLotto InvokePresaInCaricoLotto(tipoRichiestaPresaInCaricoLotto request, int tentativo)
{
result = null;
try
{
result = ProxySgate.PresaInCaricoLotto(request);
}
catch
{
if (tentativo < 5)
result = InvokePresaInCaricoLotto(request, tentativo + 1);
}
return result;
}
public string EsitoRichiestaLotto(tipoRichiestaPresaInCaricoLotto rispostaLotto)
{
if (string.IsNullOrEmpty(result.lottoMessaggi.idLotto))
return result.lottoMessaggi.idLotto;
else
return "KO";
}
public tipoRichiestaPresaInCaricoLotto GeneraRequestRichiestaLotto(string requestXML)
{
// Reding the request in XML format
XDom.Load(requestXML);
XmlNode xNodeMittente = XDom.SelectSingleNode("/Mittente");
foreach (XmlNode xNode in xNodeMittente)
{
User = xNode["login"].InnerText;
Pass = xNode["Password"].InnerText;
}
XmlNode xNodeRichiestaPresaInCaricoLotto = XDom.SelectSingleNode("/richiestaPresaInCaricoLotto");
foreach (XmlNode xNode in xNodeMittente)
{
idUltimoLottoRicevutoCorrettamente = xNode["idUltimoLottoRicevutoCorrettamente"].InnerText;
NumeroMessaggi = xNode["numeroMessaggi"].InnerText;
}
request = new tipoRichiestaPresaInCaricoLotto();
request.idUltimoLottoRicevutoCorrettamente = idUltimoLottoRicevutoCorrettamente;
request.mittente = new tipoMittente() { login = User, password = Pass };
request.numeroMessaggi = Convert.ToInt32(NumeroMessaggi);
return request;
}
}
}
0
Comments
-
iperutility wrote:but when I ran my codeunit, those got me this error : the .net interop type cannot be used in code for the classic.
Indeed you can develop the code (it will compile), but the classic runtime cannot execute it. It can only be executed in the 3-tier setup, so using a RTC (and service tier).
If the code is both to run on classic and RTC you have to check whether it's running on either of them using the ISSERVICETIER function to determine that .Net Interop code will be executed only when ISSERVICETIER = TRUE.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions