How to solve Error to Deploy C# Project using Visual Studio to AX 2012?

Viewed 690

I would like to deploy a C# project by Visual Studio, but I get this error:

Error 1 Some of report's datasets refer to the data methods from class CustAgingReport_report_Name. Business logic assembly (CustAgingReport_Report_name.BusinessLogic) cannot be found. Rebuild the Business logic Project. \SSRS Reports\Reports\CustAgingReport

Error 2 The type or namespace name 'Application' does not exist in the namespace 'Microsoft.Dynamics.AX' (are you missing an assembly reference?)

enter image description here

enter image description here

Please, could you help me. Do you have any advice?

Thanks

1 Answers

If you're developing an AX report, they can be a hassle when it comes to deployment, and many times it's not your code but the environment.

The core error is likely accurate, but the cause is the trouble. The compiled business logic assembly should be located on the report server at (default path) C:\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\CustAgingReport.BusinessLogic.dll

I'm assuming yours is missing based on the error because it can't successfully compile & deploy it.

This error can be misleading though, as I've seen the true cause be due to having multiple layers of a specific object, and I would recommend you examine every primary object associated with the report (Dynamics Project, C# Business Logic Project, related C# Business Logic Projects [i.e. SrsDrillThroughCommon]) first and check what layers each object exists in.

What happens during compile if visual studio is in the wrong layer is, it can't see the associated code that exists in another layer, thus causing the compilation to fail for dependent objects. Having a report with objects in a different layer is not necessarily a problem, it's just making sure you stand on one foot and spin the right direction when you compile.

So first, examine the objects closely in AX, and then try opening Visual Studio with an .axc file that points to the layer that all of the objects are in. To do this see https://docs.microsoft.com/en-us/dynamicsax-2012/developer/how-to-open-visual-studio-with-a-specific-configuration?redirectedfrom=MSDN . And make sure to recompile, etc to see if that alone fixes it.

A second idea is, directly trying to compile the business logic assembly (according to the error).

For example, in AX when you open a Dynamics AX Model Project, it doesn't always load the C# Business Logic Project.

You can see the sales invoice report has these two project objects in the AOT:

enter image description here

When you right click on the Dynamics AX Model Project and click Edit, it launches Visual Studio with only this in your solution explorer:

enter image description here

In VS on the left side, under the Application Explorer (View>Application Explorer if it's missing), find the associated C# Business Logic Project and double click on it to add it to your project. In my example it is SalesInvoiceReport.BusinessLogic.

enter image description here

After I do so, it also automatically adds SRSDrillThroughCommon, as that's a dependency as well. [Sidebar: SRSDrillThroughCommon is used for those blue hyperlinks to launch the related AX forms]

enter image description here

Ensuring you've launched Visual Studio in the correct layer, try recompiling everything to see if that resolves it.

Lastly, and I say lastly because this is only the last thing I happen to think of...I'll probably come up with other things later, try to do a full AX compile and deploy directly from AX by finding it in the AOT. See https://docs.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/how-to-deploy-reports-to-a-report-server for more info on that.

I've had a report so complex and troublesome that even Microsoft couldn't solve it. I suspect the reason was a bug that nobody had encountered since I was doing some really unusual development. I ultimately ended up solving it by importing an XPO of the exact same project contents into the AOT then deploying. Somehow that managed to get it working. This error is not a fun one. Good luck!

Related