K
kenhero
Guest
I tried to test a driver of a pos written in c# that needs .NET 3.5. I choosed to use NUnit for VS17 because i have a consolle application code written in C# with some functional test of the driver.
It works good but when i try to call the same method from NUnit it raises an exception.
This is the "good" application code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FiscalReceipt.Library;
namespace FiscalReceiptMain
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Setting [STAThread] ");
FiscalReceipt.Library.FiscalReceipt mc = new
FiscalReceipt.Library.FiscalReceipt();
int output = mc.testFiscalReceiptClass();
Console.WriteLine("Number of exception = {0}", output);
System.Environment.Exit(0);
}
}
}
The issue is of course inside testFiscalReceiptClass:
namespace FiscalReceipt.Library
{
public class FiscalReceipt
{
private PosExplorer posExplorer;
private PosCommon posCommonFP;
//exception counter
public static int NumExceptions = 0;
public FiscalReceipt()
{
posExplorer = null;
posCommonFP = null;
}
//Method to test the original FiscalReceiptClass
public int testFiscalReceiptClass()
{
try
{
// Console.WriteLine("Initializing PosExplorer ");
posExplorer = new PosExplorer();
}
catch (Exception e)
{
...
}
If I create posExplore object from the consolle application there is no issue but when i try to debug NUnit it raises an exception:
{"L'inizializzatore di tipo di 'Microsoft.PointOfService.Management.Explorer' ha generato un'eccezione."}
InnerException {"Questo metodo utilizza in modo esplicito criteri di sicurezza dall'accesso di codice obsoleti in .NET Framework. Per abilitare i criteri di sicurezza dall'accesso di codice a fini di compatibilità, utilizzare l'opzione di configurazione NetFx40_LegacySecurityPolicy. Per ulteriori informazioni, vedere Code Access Security Policy Compatibility and Migration."} System.Exception {System.NotSupportedException}
Sorry for italian language
It seems that Nunit is a 64bit library that's incompatible with my dll. I spent over 24 works hours to try many solution but i'm locked now.
Suggestions?
Continue reading...
It works good but when i try to call the same method from NUnit it raises an exception.
This is the "good" application code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FiscalReceipt.Library;
namespace FiscalReceiptMain
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Setting [STAThread] ");
FiscalReceipt.Library.FiscalReceipt mc = new
FiscalReceipt.Library.FiscalReceipt();
int output = mc.testFiscalReceiptClass();
Console.WriteLine("Number of exception = {0}", output);
System.Environment.Exit(0);
}
}
}
The issue is of course inside testFiscalReceiptClass:
namespace FiscalReceipt.Library
{
public class FiscalReceipt
{
private PosExplorer posExplorer;
private PosCommon posCommonFP;
//exception counter
public static int NumExceptions = 0;
public FiscalReceipt()
{
posExplorer = null;
posCommonFP = null;
}
//Method to test the original FiscalReceiptClass
public int testFiscalReceiptClass()
{
try
{
// Console.WriteLine("Initializing PosExplorer ");
posExplorer = new PosExplorer();
}
catch (Exception e)
{
...
}
If I create posExplore object from the consolle application there is no issue but when i try to debug NUnit it raises an exception:
{"L'inizializzatore di tipo di 'Microsoft.PointOfService.Management.Explorer' ha generato un'eccezione."}
InnerException {"Questo metodo utilizza in modo esplicito criteri di sicurezza dall'accesso di codice obsoleti in .NET Framework. Per abilitare i criteri di sicurezza dall'accesso di codice a fini di compatibilità, utilizzare l'opzione di configurazione NetFx40_LegacySecurityPolicy. Per ulteriori informazioni, vedere Code Access Security Policy Compatibility and Migration."} System.Exception {System.NotSupportedException}
Sorry for italian language
It seems that Nunit is a 64bit library that's incompatible with my dll. I spent over 24 works hours to try many solution but i'm locked now.
Suggestions?
Continue reading...