AX 2012 Compile error in Web Control after you updated the proxies in Visual Studio

You can run into issue when you have the object method (from class, table) which is already used by proxy. During development you decide to add a new method or change the parameters of the existing method.

After you move to Visual Studio, the proxy will be regenerated and new method/ new parameter will be available, so you can use it without any problem when developing your Web Control. Such a Web Control you will be able to compile without any issue in Visual Studio.

The problem happens when you decide to compile it in Dynamics AX Development environment. Usually when you use one of the Source Control method in Version Control > System settings usually you have setup to Reject Compile errors to be sure of integrity of checked in code.

The problem happens when you try to check in Web Control which is using freshly added method (parameter) then you get compilation error like:

Compile error:

\CatDisplayProductDetail.ascx.cs(251): error CS0117: ‘Microsoft.Dynamics.Portal.Application.Proxy.CatCartLine’ does not contain a definition for ‘method1’

 The issue happens because the proxies which are used to compiled in Dynamics AX are not regenerated to fix the problem you can:

  1.  Before compile you need to right click on AOT \ Web \Web Files \ Web controls and select “Generate Proxies for Compilation”

 

    2.       What we can also go is in \Classes\SysEPWebControlCompiler\ensureDependencies:

//generate dependencies if the existing version of dependencies is not same as current version

            if(System.IO.File::Exists(versionFilePath))

            {

                dependencyVersion = System.IO.File::ReadAllText(versionFilePath);

            }

            if(dependencyVersion != currentVersion)

            {

                this.generateDependencies();

                System.IO.File::WriteAllText(versionFilePath, currentVersion);

            }

            canCompile = true;

we can comment the line if (dependencyVersion != currentVersion) then every time when you compile web control he will update dependencies. The problem here is that it takes some time  even those you did not change any proxies, so we can have some performance degradation.