-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
error CS0122: 'ThisAssembly' is inaccessible due to its protection level #449
Comments
I believe the reason you're struggling is due to an open issue in the WPF build SDK, where it doesn't respect PackageReference in its "inner build". Your issue sounds like a duplicate of #404, though the symptom is slightly different because your WPF project references another project that also uses NB.GV, whereas in #404 that isn't the case. Basically in WPF's inner build, NB.GV doesn't get a chance to run and thus doesn't create the The good news though is there are workarounds for this. Check out #404 (and links) to learn more. |
That did the trick. Thanks! |
This issue is the first in Google results, so instead of the long chain of links I'll add a shortcut: microsoft/CsWin32#7 (comment) |
Hi there I'm on a project that uses Nerdbank.GitVersioning 3.1.68. After a number of changes updating our WPF project to .NET Core 3.1 at some point we started to see the follow error.
error CS0122: 'ThisAssembly' is inaccessible due to its protection level
To be clear this had been working. But at some point we changed our project SDK from "MSBuild.SDK.Extras" to "Microsoft.NET.Sdk.WindowsDesktop".
Of course this is because we use some of the properties from the ThisAssembly class in our code. After a number of attempts to determine the cause I finally tried defining ThisAssembly in our code as seen below.
internal static partial class ThisAssembly { internal const int IgnoreMe = 0; }
This changed all the errors all to something along the lines of the error below.
error CS0117: 'ThisAssembly' does not contain a definition for 'AssemblyVersion'
I only found a couple references to the first error online but they seemed to work around the issue by disabling GitVersioning and one eluded to the timing of when ThisAssembly is created. That would certainly explain the two different errors and the fact that I see the errors in VS after building but they very quickly disappear in the Error List panel when I navigate to the files with the errors. However, they can always be found in the build logs.
Use of GitVersioning is seems pretty straight forward and the only significant csproj file change was the SDK change. All other changes were code so I doubt they could affect this.
The text was updated successfully, but these errors were encountered: