VS2015 - IntelliSense not working in razor views in a class library

前端 未结 1 1868
生来不讨喜
生来不讨喜 2021-02-07 07:43

I am having a hard time describing the exact issue, but is appears to be \"just\" an IntelliSense problem that only shows in razor (.cshtml) views. Been looking at this for 2 da

1条回答
  •  天涯浪人
    2021-02-07 08:01

    A reply in the article Stephen Muecke commented with got me started in the right direction. The solution is a mix of probably my confusion of which config needs to be where, and what feels like a workaround to something...

    1. Set the [Output Path] of your class library project to [bin/]. Mohammad Chehab mentions this in his (currently offline?) blog post which was referenced in this article: http://thetoeb.de/2014/01/05/enabling-mvc5-intellisense-in-a-classlibrary-project/

    2. In your [ClassLibrary/Views] folder you should have a Web.config which includes the correct razor versions and namespaces. I just copied the contents of the Web.config from our working Web application project and added/changed some namespaces. Example below.

    3. In your [ClassLibrary] root folder you should change the App.config so that it also contains the system.web section with the compilation setting. Example below.

    After changing these to a clean, close the solution, delete the bin folders, open the solution and for me it finally all worked again. I do have a sporadic issue with System.Web.Mvc.xml being locked, perhaps a side effect of the output path change that MS did not foresee or something... Perhaps nothing to worry about.

    Hope this helps some poor googling soul some day.

    Project/Views/Web.config

    
    
    
      
        
          

    Project/App.config

    
    
    
      
        
      
      
        
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
          
            
            
          
        
      
    
    

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