1

We are having a problem with the Sage 200c Extra 2018 SDK when used in Web Forms.

We have created solution with library, win forms and web forms project. We have noticed that when using the 'Win Forms project' it works, but the same example in 'Web Forms project' crashes. Sage 200c SDK documentation does not exclusively talk about Win or Web forms and what configuration each may need. Could you please help us to get this working in web forms? We have an older version of the SDK working on an older version of Sage 200 v8. We have upgraded Sage 200 v8 to Sage 200c Extra 2018 Summer Enhancements and tested it with the new client and all is working. I have noticed on sage City similar questions but no answer.

Here

Here is our code sample:

Private Shared Sub FindCore200()

        ' get registry info for Sage 200 server path
        Dim path As String = String.Empty
        Dim root As RegistryKey = Registry.CurrentUser
        Dim key As RegistryKey = root.OpenSubKey(REG_PATH)

        If key IsNot Nothing Then

            Dim value As Object = key.GetValue(REGKEY_VALUE)
            If value IsNot Nothing Then

                path = TryCast(value, String)

            End If

        End If

        ' refer to all installed assemblies based on location of default one
        If String.IsNullOrEmpty(path) = False Then

            Dim commonDllAssemblyName As String = System.IO.Path.Combine(path, DEFAULT_ASSEMBLY)
            If (System.IO.File.Exists(commonDllAssemblyName)) Then

                Dim defaultAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom(commonDllAssemblyName)
                Dim type As Type = defaultAssembly.[GetType](ASSEMBLY_RESOLVER)
                Dim method As MethodInfo = type.GetMethod(RESOLVER_METHOD)
                Dim x = method.Invoke(Nothing, Nothing)
                Dim ok = 1
            End If

        End If

    End Sub

when running the application, it always crashes on

application = New Sage.Accounting.Application

Exception Type: System.TypeInitializationException Message: The type initializer for 'Sage.Accounting.Application' threw an exception.

Inner Exception: Exception Type: System.IO.FileNotFoundException Message: Could not load file or assembly 'Sage.MMSAdmin.Util, Version=19.0.0.0, Culture=neutral, PublicKeyToken=b2daa66d74953d11' or one of its dependencies. The system cannot find the file specified.

AltF4_
  • 2,312
  • 5
  • 36
  • 56
  • 1
    What exception do you get when you run this in web forms as opposed to win forms? – Expired Data Feb 15 '19 at 13:47
  • I have edited the question @ExpiredData for you – AltF4_ Feb 18 '19 at 10:29
  • 1
    What user are you running the application under? Specifically is it running through an app pool in IIS? If so, have you made sure that user has the registry key which points to the click once install location? – Expired Data Feb 18 '19 at 13:12

1 Answers1

2

Are your application pools targeted to the correct version of .net and bit architecture?

If you can physically see the assembly in the path but the app can't, it's usually down to having the wrong version of .net configured. Going from such an old version to a new one, likely requires a .net version change (2.0 to 4.5 for example). It may just be that your winforms solution is targeted to the correct config and it's definitely worth comparing your build and application settings. Check that your targeting the correct CPU architecture in your build too.

Chris3y
  • 148
  • 2
  • 9
  • 1
    Unfortunately this didn’t help, I much appreciate your help regarding the answer – AltF4_ Feb 26 '19 at 00:31
  • Are you sure you're still getting the same error message: "The system cannot find the file specified."? – Chris3y Feb 26 '19 at 15:42
  • unfortunately yes , we gave up and moved to different method to resolve the issue – AltF4_ Feb 28 '19 at 16:25
  • I am currently building an ASP.NET application that will need to integrate with Sage 200c - please can I ask what alternative method you used to connect to Sage? – Oliver Dalton Mar 26 '19 at 16:29
  • I believe the options you have are the SDK (requires developer programme membership) and the Sage 200 API. You should speak to their developer support teams for more info :) – Chris3y Mar 28 '19 at 10:39