Attempting to add a strongly typed view does not find any classes in the MVC project

后端 未结 5 741
难免孤独
难免孤独 2021-02-08 06:44

I have a very odd problem. Whenever I try to use the \"Add View\" dialog in ASP.NET MVC2 and then try to \"Create a strongly-typed view\" by selecting a \"View data class\" from

相关标签:
5条回答
  • 2021-02-08 07:12

    Figured this out, here is the solution:

    The MVC Project was referencing a bunch of service contract assemblies that where referencing a "CommonServiceContractAssembly.dll". The MVC Project was also referencing "CommonServiceContractAssembly.dll". The MVC Project and the service contract assemblies were all built referencing slightly different versions of "CommonServiceContractAssembly.dll"

    When Visual Studio 2010 was reflecting on all referenced assemblies to "Create a strongly-typed view" of I believe it wasn't sure how to handle the slightly different version of "CommonServiceContractAssembly.dll" being referenced so it didn't display the reflected "strongly typed model" possibilities for any assemblies dependent on "CommonServiceContractAssembly.dll".

    The fix is to actually force Visual Studio 2010's app domain to use the correct version of "CommonServiceContractAssembly.dll" when Visual Studio 2010 starts up. This was accomplished with a Post Build Event like the following:

    REM This is required for T4 generation from models to work properly copy "$(TargetDir)"CommonServiceContractAssembly.dll" "$(DevEnvDir)PublicAssemblies\" /Y

    So I copy "CommonServiceContractAssembly.dll" that is referenced "everywhere" into where Visual Studio will load it. After I did this everything worked properly.

    Another option would be to always ensure that all assemblies that share a common dependency are always compiled with the same version of that dependency.

    0 讨论(0)
  • 2021-02-08 07:16

    Its Because you have not build your application, First build your application and then make a view then it will show .

    0 讨论(0)
  • 2021-02-08 07:24

    Before Adding View just Build the solution and then add view it will work. if it will not work then you can again concern with me i will give you another solution

    0 讨论(0)
  • 2021-02-08 07:26

    Some types from your project are filtered out by that dialog (for example all types ending in 'Controller', or all types in the System or Microsoft namespace). It's possible that your project does not have any types that would pass through the dialog's filters.

    0 讨论(0)
  • 2021-02-08 07:31

    Please make sure that you are marking them as "Public", and compile it once before opening the AddView Dialog box.

    0 讨论(0)
提交回复
热议问题