3

Has anyone experienced an issue which the view could not load a type from the assembly since you've moved the type to a different namespace on the same assembly? The only resolution for this is for me to add a new line on the view to detect the change.

Example:
Assembly: MyProject
Initial: MyProject.View.SomeViewMode, MyProject
View: _SomeView

Moving SomeViewModel to a different folder
Assembly: MyProject
Moved: MyProject.ViewModel.SomeViewModel, MyProject
View: _SomeView
Error Encountered (Could not load type MyProject.View.SomeViewModel from assembly MyProject)
Resolution: add a new line to _SomeView

Model declaration: @model SomeViewModel

Web.config
system.web.webPages.razor
namespace:MyProject.ViewModel

Do you have other resolution for this issue? Thanks for all your help

5
  • could you add how you define SomeViewModel in _SomeView? Commented Nov 30, 2017 at 4:27
  • 1
    Its as simple as this: As far as the compiler is concerned, a class name for a compiler is the full name (namespace + class name). If you change the namespace, you have to tell the compiler. There are no other magic tricks. Off course you can move the class to a different folder but not change its namespace, then all should be fine but that is not good organization. Commented Nov 30, 2017 at 4:31
  • I've added more details to my question Commented Nov 30, 2017 at 4:31
  • Just rebuild... Sometime ASP.Net get confused and does not restart the site automatically when assemblies change (ok, there are rules, but it should not happen when you clean and build)... Or maybe you building assembly in a way that does not restart the site - than this would be exactly expected behavior... Commented Nov 30, 2017 at 4:36
  • - Clean, Build (issue still persist) - Clean Folder, TF Get, Clean, Build (issue still persist) - Clean, Build, IISReset (Issue still persist) - Add new line to view (issue resolved) I don't want to keep doing it this way though Commented Nov 30, 2017 at 4:40

1 Answer 1

1

To solve this problem you must stop IIS and clear the Temporary ASP.NET files located here: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.