Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: wwDotNetBridge - logon fail

$
0
0
Re: wwDotNetBridge - logon fail
VFP and .NET Interop
Re: wwDotNetBridge - logon fail
04/19/2012
06:16:48 AM
3HE0DGNMN Show this entire thread in new window
Gratar Image based on email address
From:
Brian Abbott
To:
Attachments:
None
Hi Rick

It still behaves the same even after adding System.Web to the assemblies loaded, I'm afraid.

PUBLIC oApplication As Sage.Accounting.Application cName = 'TEST' cPass = '' oApplication = oBridge.CreateInstance('Sage.Accounting.Application') oApplication.Connect(cName, cPass) *** No error on the above line and oBridge.cErrorMsg is empty. *** Now specify the company database to connect to oCompany = oBridge.GetPropertyEx(oApplication, "Companies[0]") *** Above line throws an error: OLE IDispatch exception code 0 from wwDotNetBridge: Contract Failure: There is no ActiveUser..

No network share, it's all happening on my local machine (Win7 64-bit).

I'll send the assembly direct to you - hope you can make something of it :-)

Thanks

Brian


You'll need the same dependent assemblies in your wwDotnetBridge calls so you need to LoadAssembly("System.Web") (or possibly the fully qualified name: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a).

That's odd though - if that was the case you'd get an error and it should bubble up telling you about the missing assembly.

You are sure there is no error message? If there's no error message and the request goes through and comes back with a result that means the call is made.

Is either wwDotNetBridge or the assembly you're calling located on a network share? That changes permissions (actually most likely it wouldn't work unless you tweak the config file).

Is the assembly standalone that you can send it to me to try?

+++ Rick ---



Hi Rick

I did as you suggested and built a 'plain vanilla' VS 2010 project to test, and that _does_ log on correctly.

The only issue I had (which may or may not relate to dotnetbridge ?) is that on compile the project initially complained about 'Referenced Assembly could not be resolved because it has a dependency conflict' - this referred to the Sage assemblies that had a dependency on System.web. The solution was to re-target the project to .Net framework 4 rather than the default .Net framework 4 Client Profile.

Brian



Brian,

All I can tell you is that it sounds like wwDotnetBridge is doing what it's supposed to and calling the function and returning a valid value, and the API that is receiving the call is not.

The other question is what actually happens when you 'logon' since you're not getting a result back they must be doing something else to track you as a user. It sounds to me like that is failing.

When I have issues with an API like this I tend to build a small C# test sample and call it directly to verify that the API works. In most cases I've found the problems are the same as with VFP, but that way one can eliminate any possible cross-application issues.

+++ Rick ---


Hi Rick

Well, I've tried all the usual stuff (reinstall with a plain vanilla installation, check file locations and paths, etc etc) and still have a problem.

The interesting thing is, if the username/password is wrong or the user is disabled or locked out, the .Connect() method correctly throws an error reporting the problem, whereas if none of these things apply there is no error thrown (and oBridge.cErrorMsg is empty); but then Sage still won't recognise the user as logged on - 'Unable to authenticate user'. Which makes me think it's likely to be something internal in their code, despite their response here:


I can’t find any previous incidents of this kind of problem occurring and there’s not really any obvious logical reason why you shouldn’t be able to connect to a company after connecting to the application object, so I’d suspect something is going wrong perhaps with references in the project

I suspect the next thing will be that they will wash their hands of it because "it's not a standard C# or vb.Net connection". Any suggestions / insight you can provide will be very welcome. Could there be any sort of object refresh issue here ? (Clutching at straws ;-)

Brian



Brian,

It sounds like wwDotNetBridge is doing it's job. I can't speak to Sage but that you have to take up with them.

If you're getting a result back or there is no error message (ALWAYS check cErrorMsg or the result value after calls) then wwDotNetBridge calls are going through. Errors don't throw when you call InvokeMethod, so if something goes wrong you have to check the return value of the method (if that indicates failure) or check cErrroMsg.

FWIW, you should also be able to call this method directly:

oApplication = oBridge.CreateInstance('Sage.Accounting.Application') lvReuslt = oApplication.Connect(cName, cPass)

since there are no specific parameters or return values (?) that are problematic for FoxPro. If you call it this way any error will throw a FoxPro error that you can check.

+++ Rick ---


Hi

I'm trying to use wwDotNetBridge to interface with Sage 200 accounts (.net 3.5). I'm failing at almost the first hurdle - logging on to Sage 200.

Having loaded the relevant Sage 200 assemblies, I then do this:

LOCAL oApplication As Sage.Accounting.Application cName = 'TEST2' cPass = 'test2' oApplication = oBridge.CreateInstance('Sage.Accounting.Application') oBridge.InvokeMethod(oApplication, 'Connect', cName, cPass)

... which follows this VB.Net code example:

' Declare the Application object used to connect. Dim application As Sage.Accounting.Application = Nothing application = New Sage.Accounting.Application ' Use the Connect method passing the username and password as strings) application.Connect("John", "orange")

Superficially this works (ie no error thrown) and if I open the Sage 200 Admin Console TEST2 is shown as an active user. However, the logon has in fact failed. When I dig around, I find that Sage.MMS.SAA.Client.ConnectionState returns 0 (not logged on) and the message 'Unable to authenticate user'.

Sage support has this to say:

As you’re not getting any error back when you call Connect, I assume that the username and password are correct.

- Are you able to log into the client UI with those details?

- Are you running your code on a web service / web site or via a WPF application?

- Are you running our connection and activecompany code across different threads?

.. to which the answer is yes, no, no.

Can anyone shed any light on why this is failing?

Thanks










Viewing all articles
Browse latest Browse all 10393

Trending Articles