-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken intellisense and aspnet warnings on WebForms projects #70
Comments
@julealgon
<Project Sdk="MSBuild.SDK.SystemWeb/4.0.88">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<GeneratedBindingRedirectsAction>Overwrite</GeneratedBindingRedirectsAction>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.Infrastructure" Version="2.0.1" />
<PackageReference Include="AspNet.ScriptManager.jQuery" Version="3.4.1" />
<PackageReference Include="Microsoft.AspNet.ScriptManager.MSAjax" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNet.ScriptManager.WebForms" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" Version="1.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="WebGrease" Version="1.6.0" />
<PackageReference Include="Antlr3.Runtime" Version="3.5.1" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization.WebForms" Version="1.1.3"/>
<PackageReference Include="Microsoft.AspNet.FriendlyUrls" Version="1.0.2" />
</ItemGroup>
</Project> {
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51867/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
} I can't really help beyond that - the issue with intellisense is down in visual studio and/or the compiler, not the SDK. I wouldn't recommend using this for 'greenfield' development (not that many people are likely to be doing that with either .net 4.x or webforms), but it is more meant to be able to build well in a CI/CD system and allow you to easily manage package updates etc. which are some of the major advantages of the new project format.
It can also be useful if you are migrating to a new aspnetcore application using systemweb-adapters. I don't know if you will be able to get any help from Microsoft on this, but I would suggest asking on some of the forums etc. to see if anyone has any insight. |
Ah, right. I wasn't looking into this at all since in our development environment for this project we all use full IIS. I appreciate the reminder though.
Oh really? I didn't realize that. Thanks for pointing it out, that's less noise to maintain in the csproj :)
Fair. I did a crude migration and just kept all the existing packages for now (same as I did on our large project here). Trimming down dependencies was going to be a next step that I was going to look into, including packages already covered by the SDK.
Again, nice to know! I'll definitely remove that as the less noise in the csproj the better. That property actually came from an executable project we migrated recently from old to SDK-style csproj and I added this explicitly there because we have a few places depending on the output path in a hardcoded manner.
That's sad to hear. I'll do a few extra tests here to confirm that nothing else in the old csproj controls this, but it looks like I might just be out of luck. I thought you'd be able to help me out in seeing what the errors were though: in particular, that cryptic error message in the first line of the file, it looks like it is somehow missing the actual error in the tooltip and I can't find it anywhere.
Yeah, we are not developing any new application using WebForms at the moment. This is a (fairly large) webforms project where most newer parts of it are actually leveraging angular inside a webforms container. However, for ultra simple/report-like pages, we sometimes still rely on new webforms pages to do it due to simplicity. Being able to fix the intellisense/errors issue would be nice but is probably not 100% critical. Intellisense somehow seems to work after I add the whole element tag (for example, to show attributes of controls and such). It is really weird what is going on there.
Had never heard of this project before. Might actually be interesting for some migration efforts we'll be doing in the near future. Thanks for bringing that up.
I'll reach out to them and post back with updates. I think you should consider marking this as a "known limitation" if you also confirmed the behavior on your side. Would help others with WebForms projects like myself in the future. This caught me by surprise unfortunately. |
I'm experiencing the same issue. In addition to no Intellisence, I'm unable to set breakpoints and debug. Only workaround I have found is to split up aspx/aspx.cs, but not a great solution with hundreds of aspx's |
@robrobrobrob As I said earlier in this thread - if you are doing ongoing development work with webforms, this project may not be the best choice for you. |
@julealgon I tried your sample project and were not getting the errors/warnings you were seeing, and so I'm curious if you would share some more information: Looks like you are using Visual Studio 2022 is that right? and which version (Community/Professional/Enterprise)? The one picture that appears to come from hovering over the root element of Default.aspx showing "ASP.NET runtime error:" does it give you the text of the error? If you are not in "release" mode, can you see if switching over to release mode makes this error appear in the "Build Output" tab at the bottom of visual studio, or does it only appear in intellisense when editing an aspx file? |
@leusbj Notice that I shared a solution with 2 projects in it: one "vanilla", and the other "converted". Are you sure you were checking the converted one, and not the vanilla one? I kept both in there for comparison purposes, but only the second project (WebApplication2) is the problematic one there.
I'm using VS2022 Professional 17.7.5. If I switch from Debug to Release, nothing changes: I'm still getting the same warning the same way:
No. There is nothing else to the message. It stops at "ASP.NET runtime error:", both in the tooltip when hovering, as well as in the warnings as you can see above.
As per the above, switching doesn't make any difference, and the warning still appears "truncated". The build output does not show the error:
|
@julealgon Thought I'd add, there is only 1 developer on my team which can successfully get intellisense on the SDK csproj in VS2022 (17.7.5 Pro, .NET Runtime 6.0.23, .NET SDK 7.0.402). So it is possible. I've tried the exact same setup without any luck. Also, developers using Rider don't have this issue with SDK csproj. |
That's fascinating! If you ever find out how this was possible, please post it here @robrobrobrob .
I had no idea Rider dealt better with this. Good to know, even if our team currently doesn't use it. |
IntelliSense was working for me until I removed Visual Studio 2019 and updated Visual Studio 2022 from 17.8.2 to 17.8.3+. So it might be related to some old component that isn't included anymore. I had reported an issue here before realizing that it was already mentioned here and specific to this project type. |
This is promising @OronDF343 ! If we could find what component that is that would be awesome! Are you sure the 2022 update was part of it breaking down though? |
It's more likely that removing 2019 is what caused it, considering others' reports in this issue. I'll maybe check on some coworkers' PCs next week and see if there is any correlation (some have older installations). |
Here is what I have been able to discover: (sample size = 7 PCs)
I was able to get IntelliSense working on my machine by installing Visual Studio Build Tools 2019, selecting "Desktop development with C++" and deselecting all of the optional features. Here is my vsconfig:
So something to do with the 2019 MSBuild core packages? |
@OronDF343 that's amazing.... it works! After closing VS, installing 2019 build tools using your steps, and then reopening my aspx files, the error squiggle lines are all gone, and after a minute or so, all intellisense is working perfectly, autocompleting both properties of existing controls and new tags from scratch. It would be great if we could spot precisely which of the components above does it, but honestly... I feel like this can already be closed at this point, that's just an optimization! Thoughts @CZEMacLeod ? |
I'd really like to know which 2019 component is required for this to work properly. It feels like it might be a 32bit component (since 2022 is 64bit) that isn't installed otherwise, but that would just be a guess. If anyone has time to try stripping out components until it works it would give a minimal solution, and require the least amount of space and updates... I would start with just MSBuild perhaps... (or the first 4 items). |
I think I have figured it out. Here is my new minimal vsconfig that works:
I selected only .NET Framework 4 targeting pack from the individual components, without selecting any workloads. This made IntelliSense work. Doing the same wthing with only the 4.5 pack did not work, it has to be 4. So the culprit appears to be .NET Framework 4 targeting pack which is only available in 2019 and below. |
@OronDF343 Great to have narrowed this down to a specific component. I wonder if using the SDK binding logging, we could find out exactly which component is trying to load the 4.0 target for intellisense. I would have expected it to use whichever target was set in the web.config (e.g. 4.8 in the example/templates). <compilation debug="true" targetFramework="4.8" /> <httpRuntime targetFramework="4.8" /> Assuming you have the 4.8 runtime or targeting pack installed. I guess another thing to test is do you get intellisense for 4.5+ features in your webforms code? (when it is working). |
@CZEMacLeod For my last test I used the sample project provided by @julealgon which is set up to target 4.7.2:
This is the same as my own test project that I tested against previously at work. As for IntelliSense framework versions, from the limited testing I've done it does seem like it is limited to Framework 4.0 features for C# snippets (in C# language version is always set to 4: Web Forms 4.5 features are only partially available. For example, strongly-types data bindings were introduced in 4.5. These limitations are not present in a regular Web Application project. I'll double-check at work in the coming week. |
From research done by @OronDF343 , it sure seems that something about the Editor pane's intellisense "needs" the 4.0 targeting pack (or runtime). And it seems true even if the main project is configured to build at a newer version, or the web.config is set to compile/run at a newer version. I haven't seen an MSBuild Friendly mechanism to trigger/initiate the install of the 4.0 targeting pack (like something that might be baked into the "Project template"). But there might be a way of letting MSBuild inform the developer that under certain circumstances it could beneficial to install the 4.0 targeting pack. MSBuild's current Since this is only needed for intellisense (mostly on webforms files), and not the actual compilation of the project or debug/run time,, it should have very strict conditionals (Only DesignTime Builds, and Only when in VisualStudio, maybe more conditions like there are at least 1 ascx/aspx item) <Target Name="AspNet_4_0_TargetingCheck" BeforeTargets="MvcBuildViews" Condition=" '$(DesignTimeBuild)' == 'true' AND '$(BuildingInsideVisualStudio)' " >
<!-- Calling this task with the 4.0 version Moniker will check to help ensure -->
<GetReferenceAssemblyPaths
TargetFrameworkMoniker=".NETFramework,Version=v4.0"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
ContinueOnError="true">
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_MvcBuildTargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_MvcBuildFullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="_MvcBuildTargetFrameworkMonikerDisplayName" />
</GetReferenceAssemblyPaths>
</Target> Doing something like the above (with ContinueOnError="true") will generate a Warning instead of an Error, that looks something like the following.
|
@leusbj I think this is a good idea in general, but wonder if it should have a couple more conditional prerequisites - detecting the existence of a webforms page for instance. Did any investigation go into adding the nuget package version of the targeting pack to the project? e.g. Maybe with something like <PackageReference Include="" Version="1.0.*" GeneratePathProperty="true" />
<TargetFrameworkFallbackSearchPaths>$(TargetFrameworkFallbackSearchPaths);$(Microsoft.NETFramework.ReferenceAssemblies.net40_Path)</TargetFrameworkFallbackSearchPaths> I'm not sure of the exact syntax required here, if the search paths would affect visual studio intellisense, or if it would need to have .NETFramework\v4.0 appended, etc. but I think there is a little more investigation required here. There is the new CoreWebForms project that is based on the systemweb-adapters project, that might have run into similar issues. Have you checked if there is a solution proposed there? |
You should be able to use new language features - you will need to set 2 things. <compiler language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4"
compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> Change the I did consider adding some code to patch up the web.config file to match the project file, but never got very far with the thought. <compilation targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" /> Should really update to match the I don't know if these should/could be done as xmlpoke actions, or better with a custom task which only makes changes if it detects a mismatch. |
@CZEMacLeod That is not the issue. My web.config is definitely set up correctly (and is working as is in the legacy Web Site project with whatever language and framework versions I set). The issue is specific to SDK-style projects. I do not think that installing the 4.0 targeting pack is a viable long-term solution as it doesn't solve the underlying issue. Legacy projects do not require this for IntelliSense to work because they use the correct framework version. This seems to me like an issue with VS. Here are the actual settings that I am using right now: <system.codedom>
<compilers>
<compiler extension=".cs" language="c#;cs;csharp" warningLevel="4" compilerOptions="/langversion:10 /nowarn:1659;1699;1701;612;618" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<compiler extension=".vb" language="vb;vbs;visualbasic;vbscript" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\"Web\" /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</compilers>
</system.codedom> <httpRuntime targetFramework="4.7.2" executionTimeout="600" maxRequestLength="2097151" requestValidationMode="2.0" maxQueryStringLength="2097151"/> <compilation batchTimeout="3600" debug="true" defaultLanguage="c#" batch="true" tempDirectory="C:\TempAspNetFiles\" targetFramework="4.7.2"> |
@OronDF343 Looks good. I am surprised you are getting the CS8025 error when using the null propagation operator in webforms as it should be compiling using the newer version of roslyn and langversion 10 as you specify. Just as a quick check - I think it should be |
@OronDF343 You're right about the fact that it looks like the issue is with VS. Unfortunately, I cannot progress that, unless someone finds a way to force VS to work correctly, or an issue with VS gets raised and the underlying problem fixed. Because these are legacy technologies, and not actively supported, I doubt you will be able to get anyone to put any effort into investigating or fixing it from Microsoft's end, but I might be wrong - especially with the new CoreWebForms project being a thing now. |
@CZEMacLeod |
I hadn't heard of that project until this mention from you @CZEMacLeod . Have you considered "joining forces" with them on this effort? Would be absolutely amazing to have not only proper support for SDK-style projects fully working with WebForms but also be able to migrate to modern frameworks. |
@julealgon I have put some effort into the systemweb-adapters project, and am looking at the stuff in corewebforms - @twsouthwick has been doing some great stuff there, some of which has actually been moved into the systemweb-adapters project. |
After migrating our main WebForms projects to use this SDK, we noticed that the intellisense on aspx files (and any others such as ascx, etc) stopped working properly. Additionally, on each opened file, an error is indicated like this at the very first line:
Autocomplete doesn't show normal
asp:
controls as well:I tried deleting the contents in the
%LocalAppData%\Microsoft\VisualStudio\[Version Number]\ComponentModelCache
folder and restarting Visual Studio. When I do that, intellisense starts working for a bit, but after a few seconds (not doing anything in VS, just time based apparently), intellisense just stops working again.To ensure this wasn't something particular to our project, I proceeded to create a brand new WebForms project using the standard VS template. I then performed the same conversion steps that we did on our real project on this minimal template, and I started observing the exact same behavior.
After the conversion, I attempted adding the
EnableWebFormsDefaultItems
msbuild flag (which I was unaware of) as well as tried using different versions of the DotNetCompiler (when we migrated our own project, we used theExcludeSDKDefaultPackages
flag).Is this a known issue? How do I fix it?
For reference, here is a solution with 2 projects from the standard template: 1 converted, and the other standard.
The text was updated successfully, but these errors were encountered: