Microsoft Access / COM / API etc

I am trying to build a tool in MS Access to work with Ayanova and I am trying to authenticate to Ayanova so we don’t have to store 2 sets of credentials, but the API is .net only and I can’t use the functions from Access.
Are there any plans to build a set of API tools to work with Access/VB?

Thanks

Hi, the AyaNova developers API is written in managed .net.

VBA for office apps such as Accessand classic VB6 can not work directly with managed objects, however they can work with COM objects because they are all COM clients and a COM client can access a .net assembly indirectly through a Com Callable Wrapper.

Note that we have not tested this with AyaNova you will be pioneering in theory it should work but I just don’t know. :slight_smile:

There are many sources of info online about creating interop type libraries from .net assemblies, this one seems pretty good:

http://www.blong.com/Conferences/BorConUK2002/Interop2/COMNetInterop.htm#CCW

If this works note that there are down sides to using this method: performance will take a hit due to marshalling necessary, you won’t get intellisense help in Access such as you would get if using a managedenvironment likeVB.NETbecause AyaNova methods are not marked internally with the attribute necessary to support early bound interfaces and any app you create would require registering the type library on the end users computer to stuff the registry with the necessary settings so deployment would be far more complex than with a managed application created in a .net development environment.

In other words if you have any choice at all on what development tool to use I highly recommend you use a managed development environment such asVB.NET instead (if you are already familiary with VB, there are plenty of other choices as well) as you can then just work directly with the AyaNova developers API andget the full intellisense assistance, as well deployment is as simple as dropping your executable in the AyaNova program folder etc and we would be able to give you far better support here since that’s an environment it’s designed to work in.

Visual studio 2008 Express edition is free and available here: http://www.microsoft.com/express/default.aspx

Thanks for your reply,

I downloaded the latest version of API from your web site and none of the assemblies are included (GZTW*.dll).

I have old Ayanova 3.1 dlls and they don’t seem to work with Ayanova 4.

Do you have a new version of these files and will they be available for download?

Thanks,

Alex

amilojko (6/24/2008)Thanks for your reply,

I downloaded the latest version of API from your web site and none of the assemblies are included (GZTW*.dll).

I have old Ayanova 3.1 dlls and they don’t seem to work with Ayanova 4.

Do you have a new version of these files and will they be available for download?

Thanks,

Alex

Hi Alex, the assemblies never need to be included becauseyou use the api files that come freelywith AyaNova already installed, the api you download from us isn’t an api, it’s documentation and sample projects, you already have the api when you install AyaNova.

AyaNova the program and it’s add-on’s use the exact same api that you would use for development, it’s right there in the program folder. You don’t even need to buy AyaNova to develop for it because the trial comes with the exact same api files.

3.1 is pretty old but there’s no reason you can’t use it for development though I highly recommend you upgrade to the latest AyaNova because all the documentation for the API, the sample projects etc are all for v4.x and v4 is a significant change and improvement from the old 3.x era stuff.

Right,

thanks I didn’t even think to look into Program files for those dlls.

Cheers

amilojko (6/24/2008)Right,

thanks I didn’t even think to look into Program files for those dlls.

Cheers

The documentation would have been a great place to start! :wink:

Cheers!

Hi guys. I was contracted to work on exactly this same issue - making Ayanova API accessible from Visual Basic in Access. I managed to put together a .NET wrapper project (very simple at the moment), register it using the regasm utility, and access the API functions from Access. One odd thing I ran into - when I check the AyaBizUtils.ExpiryDate property right after running AyaBizUtils.Initialize(), it always shows the current time and date. So no matter what, the Expired property is always true, and the DB is read-only. Any idea why this may be? It only seems to happen when I run Initialize in a method exposed to COM. I worked through the CSHelloAyaNova sample in .NET with no problem at all.

I can provide examples of what I did if anyone is interested. Thanks a lot for any feedback.

zammer (7/15/2008)Hi guys. I was contracted to work on exactly this same issue - making Ayanova API accessible from Visual Basic in Access. I managed to put together a .NET wrapper project (very simple at the moment), register it using the regasm utility, and access the API functions from Access. One odd thing I ran into - when I check the AyaBizUtils.ExpiryDate property right after running AyaBizUtils.Initialize(), it always shows the current time and date. So no matter what, the Expired property is always true, and the DB is read-only. Any idea why this may be? It only seems to happen when I run Initialize in a method exposed to COM. I worked through the CSHelloAyaNova sample in .NET with no problem at all.

I can provide examples of what I did if anyone is interested. Thanks a lot for any feedback.

Hi Zammer, interesting. I’m glad to hear you got a wrapper working (at least basically), I was pretty curious about it myself.

I’m sure you have already but double check the really obvious stuff like the config.txt file, make sure you can connect and login to the exact same database using the same config.txt file withthe windows appAyaNova.exeetc etc.

The Expired property can return true under a couple of conditions:
If you are using a biz object .dll for version 4 but have a v3 license in the database.
If it’s a trial license key and passed the 30 day trial or whatever date was set by us if it was a licensed trial

The ExpiryDate property should only be returning an actual date if it’s a time limited license key like a trial or DateTime.MaxValue if it’s not.

Returning current date and time sounds as though it’s not intializing properly as that would be a default value it’s initialized to before any processing takes place.

Try the staticAyaBizUtils.View() method which returns a string, it should show you all the info about the license whether it’s a trial or not just after you make the call to Initialize(). If the View method returns “Invalid Data” then it’s somehow not really initializing properly.

I’m sure many people would like to see the examples of what you did feel free to post them here in this or another thread. Let me know what you see with the above info I’ve provided. I’d like to find out definitively if this will work or not from COM and if any changes are required at our end to get it working if that’s required and possible.

Cheers!

Thanks for the prompt feedback John! It turns out that my problem was indeed with the license. Strange, though - when logging into the Ayanova application, I would see a messagebox pop up and tell me that my registration expires 07/31/2008. However, when I used the AyaBizUtils.View() function you mentioned, I would see the following info:

Key issued: 2/25/2008

Registered to: Unregistered trial

Version: 4.1.X

Schedulable users: 5

I requested a new license key from your support department, quickly received and applied it, and now everything works fine and as expected. I’m not sure what exactly the issue with the original license key was, but whatever it was, the new key resolved it and I’m all set!

As far as a sample of what I did - here is a little code excerpt from my wrapper project:

<hr>

using System;

using System.Runtime.InteropServices;

using System.Threading;

using System.Windows.Forms; // for MessageBox during testing

using GZTW.AyaNova.BLL;

namespace AyaWrapper {

/// &lt;remarks&gt;

/// AyanovaAPI provides all the methods and properies available to Access VBA. The class GUID is set so it's always the same thing

/// when registering/unregistering the assembly for COM. Note that we may want to implement the IDisposable interface for better

/// memory management if memory usage becomes an issue.

/// &lt;/remarks&gt;

/// &lt;example&gt;

/// Here's example usage of the AyanovaAPI class to log in using Visual Basic in Access:

/// &lt;code&gt;

///		Dim oAyaWrapper As Object

///		Set oAyaWrapper = CreateObject("AyaWrapper.AyanovaAPI")

///		MsgBox "Ayanova logged in user GUID: " + oAyaWrapper.Login("manager", "letmein"), vbOKOnly, "AyaWrapper Test"

/// &lt;/code&gt;

/// &lt;/example&gt;

[Guid("140FA98F-BF85-4d23-93BD-6F5150EDBA04")]

public class AyanovaAPI {

	/// &lt;summary&gt;

	/// Default constructor is required by COM Interop, but we have nothing to do so we just leave it empty

	/// &lt;/summary&gt;

	public AyanovaAPI() { }



	/// &lt;summary&gt;

	/// Establishes a connection to Ayanova database, and attempts to log in using the username and password supplied.

	/// &lt;/summary&gt;

	/// &lt;param name="_username"&gt;Ayanova username&lt;/param&gt;

	/// &lt;param name="_password"&gt;Ayanova password&lt;/param&gt;

	/// &lt;returns&gt;If the login was successful, the GUID of the user object. If the login failed for any reason or if Ayanova is expired,

	/// returns the empty string.&lt;/returns&gt;

	[ComVisible(true)]

	public string Login(string _username, string _password) {

		// The call to Initialize is always the first required in any 

		// application working with AyaNova, it initializes the database

		// connection and business object framework and confirms operations can 

		// take place. If Initialize fails, the config.txt file is the most likely culprit.

		try {

			GZTW.AyaNova.BLL.AyaBizUtils.Initialize();

		} catch {

			// In the case of any exception using the AyaNova business object library

			// it is the Inner exception which is most likely the actual error (if present)

			// because AyaNova objects are invoked through a factory method which wraps any actual exception

			// generated by the business object inside a TargeInvocationException



			// while (ex.InnerException != null) ex = ex.InnerException;

			// MessageBox.Show("Ayanova error: " + ex.Message);



			return "";

		}



		// MessageBox.Show(AyaBizUtils.View());   // View provides information about the license. Useful for testing ...



		// Once the application gets to this point right after Initialize without error

		// we can be assured that we have a clean configuration file and a connection 

		// to the database and are ready to log in

		AyaBizUtils.Login(_username, _password);



		//confirm the user is logged in:

		if (Thread.CurrentPrincipal.Identity.IsAuthenticated == false) {

Nice one Zammer! Thank you for publishing that info I appreciate it and no doubt many will find it helpful. Were you able to manipulate AyaNova objects with it after logging in?

As for the license it sure sounds like you were pointing at a fresh trial database that had not yet been opened in AyaNova when you first tried it with your code and not the same one you were opening in AyaNova.exe.