Need help with desktop app Entitlement API

Need help with desktop app Entitlement API

ianteneth
Advocate Advocate
1,188 Views
8 Replies
Message 1 of 9

Need help with desktop app Entitlement API

ianteneth
Advocate
Advocate

I think I am missing something simple, but I am having trouble getting the Entitlement API to work. I have read the relevant Mod the Machine articles, but it is still not working for me.

 

My app is a desktop app in C# for Inventor 2020.

The "Autodesk App Store: Entitlement API for desktop Apps" pdf from the ADN has the following code for Inventor to get the user ID. This code fails to find the "AdWebservices" dll.

 

 

 [DllImport("AdWebServices", EntryPoint = "GetUserId", CharSet = CharSet.Unicode)]
 private static extern int AdGetUserId(StringBuilder userid, int buffersize);

 

 

Alternatively, Mod the Machine shows that you should import "AddinNETFramework.AdWebServicesWrapper.dll" and use the following code to get the user ID. This code just crashes without a meaningful error ("External component has thrown an exception"). And I believe that this is tailored for add-ins given that the dll has Addin in the name.

 

 

CWebServicesManager mgr = new CWebServicesManager();
bool isInitialize = mgr.Initialize(); // crashes here.
// ...

 

 

Does anyone know the correct approach for desktop apps? Is it different from add-ins?

 

Thanks!

0 Likes
1,189 Views
8 Replies
Replies (8)
Message 2 of 9

YuhanZhang
Autodesk
Autodesk

In Inventor 2020 the Entitlement API has a change so the adWebService does not work as before, but you can refer to below post to find a workaround(i.e. calling Inventor.Application.Login):

 

https://forums.autodesk.com/t5/inventor-customization/inventor-2020-regression-with-entitlement-api/...

 

Hope it helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 9

ianteneth
Advocate
Advocate

Thanks for the reply. I have looked at the post you mentioned. Below is the code I am working with. It is a direct copy from the relevant Mod the Machine articles. It is still crashing. I have attached a portion of the exception for someone to review.

 

And am I really supposed to use the "AddinNETFramework.AdWebServicesWrapper.dll". This isn't for use in Add-ins, which the original poster in the post you mentioned is developing? Is this the same workflow for desktop apps? I am not impressed with the documentation in this area. Especially since the method you are encouraging me to use is completely different from the ADN method; which is also not working for me.

 

 

 bool isLoggedIn = Inventor.Application.Login(); // No effect on crash error.
                    
 CWebServicesManager mgr = new CWebServicesManager();

 bool isInitialize = mgr.Initialize(); // Still crashes here.

 if (isInitialize == true) {

    string userId = "";

    mgr.GetUserId(ref userId);

    string username = "";

    mgr.GetLoginUserName(ref username);

 }

 

 

0 Likes
Message 4 of 9

ThomasRambach
Advisor
Advisor

@ianteneth same exact issue I'm having. Waiting for the support ticket to be picked up.

0 Likes
Message 5 of 9

ianteneth
Advocate
Advocate

Still waiting on a solution to this. To reiterate, I am creating a desktop application and none of the proposed Autodesk or Mod the Machine solutions have worked. Below is the Autodesk code used in your proposed solution where the error occurs as well as my attempt to figure out what is causing this problem.

 

The code fails when calling the Initialize() method in the CWebServicesManager class. Seen below, this method appears to just call another method in the WebServicesManager class.

 

// Assembly location: C:\Program Files\Autodesk\Inventor 2020\Bin\AddinNETFramework.AdWebServicesWrapper.dll
// Autodesk.WebServices.CWebServicesManager
[return: MarshalAs(UnmanagedType.U1)] public bool Initialize() { if (this.IsInitialized()) return true; return <Module>.Autodesk.WebServices.WebServicesManager.Initialize(); }

 

Below is the entire WebServicesManager class. It contains no Initialize() method nor much of anything else. Is this correct? Is my reading of this code correct? Can someone please address this issue.

 

 

// Assembly location: C:\Program Files\Autodesk\Inventor 2020\Bin\AddinNETFramework.AdWebServicesWrapper.dll
// Autodesk.WebServices.WebServicesManager namespace Autodesk.WebServices { [NativeCppClass] [StructLayout(LayoutKind.Sequential, Size = 8)] internal struct WebServicesManager { private long <alignment member>; } }

 

 

0 Likes
Message 6 of 9

ThomasRambach
Advisor
Advisor

@iantenethAutodesk has marked this as a known issue through the support system. They told me it's with engineering to figure out a solution. I think we all have to collectively keep asking for a solution.

Message 7 of 9

ianteneth
Advocate
Advocate

@ThomasRambachHave you heard anything on this topic?

0 Likes
Message 8 of 9

HideoYamada
Advisor
Advisor

Hello,

 

My code works with Inventor 2020.

I've written in the blog about it and the blog contains sample code... but my blog is written in Japanese!

Autodesk Inventor API Hacking (Entitlement API) 

You must translate it by google translate or something, but I hope my blog helps you.

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 9 of 9

ThomasRambach
Advisor
Advisor

@HideoYamada I'll see if Google Translate can get me far enough on your post to decipher it. Thank you.

 

@ianteneth I have an alternate method I'm trying out now.

0 Likes