The type initializer for 'Microsoft.PointOfService.Management.Explorer' threw an exception

3.9k Views Asked by At
Imports Microsoft.PointOfService

Public Class Form1
   Public Sub New()
      InitializeComponent()
         myexplorer = New PosExplorer(Me)

I get the exception 'The type initializer for 'Microsoft.PointOfService.Management.Explorer' threw an exception' at the above line.

I'm using Microsoft.PointOfService.dll assembly, but I has not installed the POSfor.NET.msi in my client machine.

Is there a way to access PosExplorer with out installing anything extra??, why it doesn't work by just adding the assemblies? If I install it, it is installing everything including SDK/samples which doesn't require at production.

2

There are 2 best solutions below

1
On

There are a bunch of registry keys that are created with you run the PosFor.NET installer which help it locate control assemblies and the configuration XML files. If you don't run the installer you won't have these registry keys and will probably have trouble using the POS libraries.

That said, there's also a problem that arises when using even a properly installed POSfor.NET with .NET 4 that will result in an exception like the one you're seeing. Have you looked at the inner exception there to see what the actual error is?

If you are using .NET 4, and the inner exception there it's a CAS security policy exception you need to add this entry to your app.config file:

But I expect you will still have problems getting stuff to work without a proper installation of the POSfor.NET package.

0
On

I found out what the problem of your error.probably you are using POS on .NET 4 and needed the following code.

<configuration>
<runtime>
<NetFx40_LegacySecurityPolicy enabled="true"/>
</runtime>
</configuration>