Solved

ClassGenertor Issue

  • 13 August 2023
  • 11 replies
  • 135 views

Userlevel 2
Badge

Hi,

Im having problem generating page wrapper with ClassGenerator tool. Its config looks like

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="SitePhysicalPath" value="C:\Acumatica\PhoneRepairShop1" />
    <add key="GenResultPath" value="C:\Acumatica\Plugins\Test SDK\ClassGenerator\Out" />
    <add key="Username" value="tmuser@TIGER" />
    <add key="Namespace" value="GeneratedWrappers.Acumatica" />
    <add key="ClearOutput" value="false" />
    <add key="FilenameFilter" value="*GL301000*" />
    <!--<add key="PagesList" value="list.txt"/>
    <add key="PagesListAttribute" value="exclude"/>
    <add key="PagesListAttribute" value="include"/>
    <add key="PagesParameters" value="ParamsPP.txt"/>
    <add key="GenericInquiryParameters" value="ParamsGI.txt"/>-->
  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
  </startup>
</configuration>

 

When I run ClassGenertor tool. I got this issue:

 

Process FAILED - GL301000
System.IO.FileLoadException: Could not load file or assembly 'PX.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b136cac2f602b8e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'PX.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b136cac2f602b8e'

Server stack trace:
   at ClassGenerator.Host.MyProxy.Process(String uri, String user, String screenID, String genResultPath, String postfix, String Namespace, Boolean corectCTL01)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ClassGenerator.Host.MyProxy.Process(String uri, String user, String screenID, String genResultPath, String postfix, String Namespace, Boolean corectCTL01)
   at ClassGenerator.ScreenExtractor.GetScreen(ScreenMeta screenMeta) in C:\Bld2\AC-FULLCOMMON145-TB\tests\Selenium\ClassGenerator\ClassGenerator\ScreenExtractor.cs:line 52
   at ClassGenerator.ClassGenerator.Run() in C:\Bld2\AC-FULLCOMMON145-TB\tests\Selenium\ClassGenerator\ClassGenerator\ClassGenerator.cs:line 181

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

System.ApplicationException: Wrapper generation process failed, see log for details
   at ClassGenerator.ClassGenerator.Run() in C:\Bld2\AC-FULLCOMMON145-TB\tests\Selenium\ClassGenerator\ClassGenerator\ClassGenerator.cs:line 193
   at ClassGenerator.Launcher.Main(String[] args) in C:\Bld2\AC-FULLCOMMON145-TB\tests\Selenium\ClassGenerator\ClassGenerator\Launcher.cs:line 11

icon

Best answer by AaronB 4 October 2023, 16:54

View original

11 replies

Userlevel 7
Badge +11

Hi @hotdok,

I assume that you are getting issues with the URL path.

One way is to escape all characters that are special to C#. In this case, the double quotation mark (") is used to denote the end of the string, and the backslash (\) denotes a C# escape sequence. Both need to be prefixed with a backslash (\) to properly escape them in C#.

Eg)
<add key="SitePhysicalPath" value="C:\\Acumatica\\PhoneRepairShop1" />
    <add key="GenResultPath" value="C:\\Acumatica\\Plugins\\Test SDK\\ClassGenerator\\Out" />
 

The other way is to prefix the string with @ and escape only the double quotation marks by replacing them with two double quotation marks (""):

Eg)
string a = @"C:\\Acumatica\\PhoneRepairShop1";

Userlevel 2
Badge

Hi @jinin ,

Thanks for advice. Due to Test SDK docs its ok to have unescaped path. Also I have check inputting incorrect path and it gave me acumatica not found error

 

Userlevel 4
Badge +2

Can you log into the site?  I generally get this message when my site is hosed for whatever reason.  

Userlevel 2
Badge

Hi @Patrick Chen 

Yes I can login with specified user. Acumatica works fine

Userlevel 4
Badge +1

Hello @hotdok 

Acumatica recommends doing classgeneration via TestSDK code for ISV partners and is a requirement to do it as such to certify your solution.

See the below guide, test.cs line 23 for the method. The readme and also the word documents  inside the project will have the correct steps laid out clearly.

https://github.com/Acumatica/Test-SDK-Starter-Guide

Please note you should actually download the git project and rename it - deleting unused files and use it as your test base solution to ensure compatibility.

 

A common reason for wrappers to not generate on a version update or first time run is because you must update the nuget repository manually using the “packages” folder contents of the testSDK official download zip. Then update the project dependencies to the newly added & version matching ones to the test project/site.
This is all explained in the How to generate Wrappers” guide inside the git project above.

Userlevel 2
Badge

Hi @AaronB 

Thanks for reply. I used latest test SDK 21.225.0006 I found. But Im using acumatica version 22.208.0012 so I think this may be the reasone. Also I found “How to Generate Wrappers.docx” file with code snippet. I updated it and integrated into my test solution. Now I see more logs:

 

=== Pre-bind state information ===
LOG: DisplayName = PX.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b136cac2f602b8e
 (Fully-specified)
LOG: Appbase = file:///C:/Acumatica/PhoneRepairShop1/
LOG: Initial PrivatePath = C:\Acumatica\PhoneRepairShop1\bin
Calling assembly : Host, Version=21.225.6.7, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Acumatica\PhoneRepairShop1\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: PX.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b136cac2f602b8e
LOG: Attempting download of new URL file:///C:/Acumatica/TemporaryAspFiles/PhoneRepairShop1/testgen/e0fc5271/cebacbcd/PX.Web.UI.DLL.
LOG: Attempting download of new URL file:///C:/Acumatica/TemporaryAspFiles/PhoneRepairShop1/testgen/e0fc5271/cebacbcd/PX.Web.UI/PX.Web.UI.DLL.
LOG: Attempting download of new URL file:///C:/Acumatica/PhoneRepairShop1/bin/PX.Web.UI.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

 

So it looks like publicToken keys are different for wrapper generator and acumatica release. How this could be fixed?

Userlevel 5
Badge +1

Hi @hotdok 

The error message you're seeing, System.IO.FileLoadException: Could not load file or assembly 'PX.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b136cac2f602b8e' or one of its dependencies, suggests that there might be an issue with the version of the assembly that your ClassGenerator tool is trying to load.

Here are some steps to troubleshoot and potentially solve the issue:

  1. Verify Assembly Version: First, make sure that the version of the 'PX.Web.UI' assembly being referenced in your application matches the version specified in the error message. This assembly should be available in the 'bin' directory of your Acumatica instance. You can use a tool like ILSpy or simply right-click the DLL, select Properties, and go to the Details tab to see the version.

  2. Update References: If the versions do not match, you might need to update the references in your ClassGenerator tool. Right-click the project in Visual Studio, select 'Manage NuGet Packages', and ensure that you're using the correct version of the 'PX.Web.UI' assembly.

  3. Clear Temporary Files: Sometimes, these issues can be caused by old versions of assemblies being cached in the Temporary ASP.NET Files folder. Try clearing the content of this folder. The folder can typically be found at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files.

  4. Rebuild Your Project: In Visual Studio, right-click your project and select 'Rebuild'. This will clean your project and build it again, which can sometimes resolve these types of issues.

  5. Assembly Binding Logging: The error message suggests turning on assembly bind failure logging by setting a registry value. This can provide more details on why the assembly could not be loaded. Run regedit and navigate to HKLM\Software\Microsoft\Fusion. Add a DWORD value named EnableLog and set it to 1. Be cautious when editing the registry; incorrect changes can cause problems with your system.

  6. Check for Redirects in Web.Config: Sometimes, assembly binding redirects defined in the web.config file can cause issues. Check the web.config file for any binding redirects related to 'PX.Web.UI' and ensure they are correct.

  7. Dependencies: The error message indicates that the issue could also be with one of the dependencies of the 'PX.Web.UI' assembly. Make sure that all dependencies are present and of the correct version.

  8. Compatibility: Ensure that your Acumatica instance and the ClassGenerator tool are compatible versions.

If none of these steps resolves the issue, you might need to dig deeper into the ClassGenerator tool itself or consult with Acumatica support or developers familiar with the tool.

Userlevel 2
Badge

Hi @davidnavasardyan09 

I have reversed engineered Host.dll from ClassGenerator tool and found it references PX.WEB.UI.dll with PublicKeyToken=3b136cac2f602b8e and acumatica of version 22.208.0012 references without PublicKeyToken. When I tried to add public token to acumatica it stops compiling so the issue is public key tokens difference. It looks like ClassGenerator was developed for acumatica of 21 version on 22 but may be Im mistaken. 

Userlevel 7
Badge

Hi @hotdok were you able to find a solution? Thank you!

Userlevel 2
Badge

Hi @Chris Hackett 

No I think the problem is with PX.WEB.UI.dll PublicKeyToken compatiblity. I was not able to solve it. 

Userlevel 4
Badge +1

Hi @hotdok,

Edit: seems I gave a similar response already. 
Something else to try
1. Delete the classgenerator and any other relevant package from your nuget cache to ensure you download and use fresh references C:\Users\username\.nuget\packages
2. Ensure your %appdata%\NuGet NuGet.config is pointing to valid paths​​​​​​​

3.The Acumatica website, and TestSDK download must be the exact same version. 22.207 will not work with 22.208. If you are using the 21.225 nuget references for sure it will cause major problems like this.

 

My previous written comment may still help and is valid feedback so I will leave it below

____________________________________

I must agree with @davidnavasardyan09 It looks like you have to update your project references, or you may be using the wrong version of .net in your project.

I highly recommend downloading the TestSDK project I have shared here and using it as your new test project. Follow the steps in the readme to configure it then pasting your existing test code into the project.

https://github.com/Acumatica/Test-SDK-Starter-Guide

Note: we recommend using the GenerateWrappers() method form the above to generate your wrappers now, it uses the same code on the backend but it brings the wrapper generation process into the source control instead of a manual config step each tie you update.

 

The likely solution to your issue from the Readme:
In your test project inside Visual Studio:

  1. Remove all the old Dependencies -> Packages
  1. Go to Manage Nuget Packages -> Add a new package source and add the packages folder from C:\AcumaticaTestSDK\TestSDK_23_200_0144_156\packages
  1. Add all references from the new source to the project

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved