web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Reference to System.Web.Optimization

(0) ShareShare
ReportReport
Posted on by

Hello,

I have visual studio web project, which uses framwork 4.0 (need some json functions and mcv4).

Compile is fine in Visual Studio environment, but when I compile via AX, I see messages of lower framework

(‎‎‏ CS0234: The type or namespace name 'Json' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?) - that's for using System.Runtime.Serialization.json;

Even for framework 3.5 (I remark this line), I got another message, for using System.Web.Optimization.

 

I don't know why, but I succeeded compiling it before with no problem.

I have two project. now is web application, and one is library.

Both are on AOT.

 

When I open the Visual studio C# application, the library is also opening,

When I open the Visual studio C# library, the library is opening on framework 3.5, but when I look on the references, I see that there are from framework 2.0.

 

I change the framework to 4.0, and I see I need to add the project to AOT - I did that, recompile CIL (incremental), but still cannot compile the project using the Visual studio files (I got the same errors).

 

‎‎‏ CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

 

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Compilation from AX of Visual studio compile lower framework.

    I see the following in web.config:

      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="None" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Optimization" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
    


    ... but I don't know whether this is related.

    Thanks :)

  • Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Compilation from AX of Visual studio compile lower framework.

    I tried to reproduce your problem: I created a class library for .NET 4.0 (that's the right version to use with AX 2012), referenced System.Runtime.Serialization assembly and added a method using DataContractJsonSerializer class. Then I added the project to AOT and compiled it in AX.

    I didn't get any error, therefore I can't either reproduce or analyze your problem.

    Please try such a trivial library to be sure that the issue isn't caused by some other component. When it's confirmed, we can start thinking about why the binding fails.

  • Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Compilation from AX of Visual studio compile lower framework.

    Regarding versions 3.5 and 2.0, you might be confused by the fact that .NET Framework 3.5 is built upon CLR 2.0 (= .NET runtime).

  • Community Member Profile Picture
    on at
    RE: Compilation from AX of Visual studio compile lower framework.

    I have realized when the problem occured:

    I just added an empty MCV4 project to AOT as following:

    1. Downloaded from http://www.microsoft.com/en-ca/download/details.aspx?id=30683.

    2. Open Visual studio.

    3. Add new MCV4 project.

    4. Add the MCV4 to AOT.

    5. Compile the project from AX.

    The MCV4 is empty default project, still got the error:

    CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

    That is for the source: \App_Start\BundleConfig.cs

    Also error:

    CS0246: The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?)

    for: \Controllers\HomeController.cs


    Also error:

    CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

    for: \Global.asax.cs


    Also error:

    CS0246: The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?)

    for: \App_Start\BundleConfig.cs


    Also error:

    CS0246: The type or namespace name 'GlobalFilterCollection' could not be found (are you missing a using directive or an assembly reference?)

    for: \App_Start\FilterConfig.cs


    also error:

    CS0246: The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?)

    for: \Controllers\HomeController.cs


    There was no problem before, but for now - I have that kind of problem. I don't know what may cause the problem - compilation from Visual Studio is OK, but from AX, it is not OK.

    Thanks :)

  • Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Reference to System.Web.Optimization

    I think that System.Web.Optimization isn't included in .NET Base Class Library. It's a part of Microsoft ASP.NET Web Optimization Framework and you haven't installed it anywhere where the AX client can find it.

  • Community Member Profile Picture
    on at
    RE: Reference to System.Web.Optimization

    What I did is adding MCV4 as the link:

    www.microsoft.com/.../details.aspx

    Also, re installed it again.

    That shall influence the Visual Studio - not AX.

    I didn't add any web optimization framework and things worked fine (I don't know since when it didn't)

    Now - same scenario, same compilation, but code is not compiled.

    I shall notice that I compiled the code with best practice, and saw those errors as warning on best-practice, but it still compiled (I don't know whether BP compilation is related).

    That was the last change before code wasn't compiled.

    Thanks :)

  • Suggested answer
    Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Reference to System.Web.Optimization

    The project templates contain a NuGet package for Microsoft ASP.NET Web Optimization Framework. It's installed under your Visual Studio project and AX won't be able to find it.

    You'll have to install the DLL(s) for the Web Optimization Framework to a place where AX client looks for assemblies to load (I think you have three options: the bin folder, the VSAssemblies folder and GAC).

    I understand that things like NuGet and assembly probing are new for an AX developers, but you have to learn them to be able to develop in .NET.

  • Community Member Profile Picture
    on at
    RE: Reference to System.Web.Optimization

    You mean copy the dlls to: C:\Program Files\Microsoft Dynamics AX\60\VSTools\Bin or to C:\Windows\Assembly?

    Shall I restart the AOS service, or just refresh the AOS (tools -> Refresh cache -> ...)? Without restart AOS is the preferred way.

    Shall I build the CIL (incremental)?

    Thanks :)

  • Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Reference to System.Web.Optimization

    Compilation runs on client, therefore it's not related to AOS.

    You may need it on AOS for executing your code, though, if it runs on server. I think it would work without restart, but I'm not sure - simply go and try it. Caches in Dynamics AX have nothing to do with .NET assembly binding.

  • Martin Dráb Profile Picture
    236,316 Most Valuable Professional on at
    RE: Reference to System.Web.Optimization

    Is your question answered now? If it is, please mark it as answered.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans