What is the correct way to use internationalization in a Asp.net 5 MVC project ?
If I try to decorate my model classes with DisplayName for example, Visual Studio gives me an error:
Severity Code Description Project File Line
Error CS0246 The type or namespace name 'DisplayName' could not be found (are you missing a using directive or an assembly reference?) MyProject.DNX Core 5.0 C:\Users\paulo\Documents\Visual Studio 2015\Projects\MyProject\src\MyProject\Models\Post.cs 20
I canĀ“t even create a resource file in this type of project.
You need to reference and import the namespace that defines this attribute:
`using System.ComponentModel;`
Related
I am working with .net core 5. I have folder structure like below.
Project
Project core
Project business
Project infrastructure
In "Project", System namespace working fine. But in other "Project" directory it shows error for namespace "System"
Here is the one which i am getting in output
NuGet package restore failed. Please see Error List window for detailed warnings and errors
Few more errors in error list i am facing are as below
I renamed my project, and updated it to .Net 5. Now, I obviously havent catched all the occurances since I get this error:
\source\repos\BlazorBattles\BlazorBattles\Server\obj\Debug\net5.0\Razor\Pages\Error.cshtml.g.cs(78,71): error CS0246: The type or namespace name 'blazor_battles' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\hagenek\source\repos\BlazorBattles\BlazorBattles\Server\BlazorBattles.Server.csproj]
However, it is hard to locate it, because the error shows a file that is being generated by the project ,not a file that is in the core project.
Any tips?
For some reason visual studio could not locate the string "blazor_battles" in the Error.cshtml file inside of Server/Pages directory.
Using hyphens in your project names creates problems. Don't do it.
I make my project based on this tutorial:
https://learn.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-3.1&tabs=visual-studio
It told me that it is missing directive or an assembly reference.
But I instal the related plugin, and the code generate successfully, I don't know why VS still can't find the code...
Here is the code content, the namespace is exist:
More info my proto properties:
Error Msg:
1>MainWindow.xaml.cs(6,7,6,23): error CS0246: The type or namespace
name 'HeartBeatMessage' could not be found (are you missing a using
directive or an assembly reference?)
1>MainWindow.xaml.cs(16,24,16,40): error CS0246: The type or namespace
name 'HeartBeatService' could not be found (are you missing a using
directive or an assembly reference?)
I found this question because I was running into this problem too. See: https://github.com/grpc/grpc/issues/20402
For now, I have manually moved the generated .cs files into my project and disabled the build step on the .proto (otherwise VS will complain about double definitions).
I have created a new Web API project using the ASP.NET 5 Templates. I am wanting to generate random numbers using System.Security.Cryptography.RandomNumberGenerator but it is not available in the .NET Platform 5.4 (see screenshot).
Compiling it also generates the following errors:
Error CS0234 The type or namespace name 'Cryptography' does not exist in the namespace 'System.Security' (are you missing an assembly reference?)
Error CS0246 The type or namespace name 'RandomNumberGenerator' could not be found (are you missing a using directive or an assembly reference?)
Error CS0103 The name 'RandomNumberGenerator' does not exist in the current context
Is there a way to use this or is there an alternative random generator that I can use which is cryptographically secure?
I got it working thanks to Scott Chamberlain's comment by adding the System.Security.Cryptography.Algorithms NuGet package.
I also had to modify the project.json so it was only a dependency of dotnet5.4 and not a global dependency otherwise the compiler would complain that RandomNumberGenerator exists in both System.Security.Cryptography.Algorithms and mscorlib.
I just started using WiX, with zero knowledge of C#/.NET
Now I'm trying to create a simple WiX extension by referring this page: WiX3 - Simple Example of Extension.
Here is steps described in that page:
In Visual Studio, create a new C# library (.dll) project named SampleWixExtension.
Add a reference to wix.dll to your project.
Add a using statement that refers to the Microsoft.Tools.WindowsInstallerXml namespace.
using Microsoft.Tools.WindowsInstallerXml;
Make your SampleWixExtension class inherit from WixExtension.
public class SampleWixExtension : WixExtension {}
Add the AssemblyDefaultWixExtensionAttribute to your AssemblyInfo.cs.
[assembly: AssemblyDefaultWixExtension(typeof(SampleWixExtension.SampleWixExtension))]
Build the project.
However, when I finished these steps and built this project, I met following errors:
------ Build started: Project: SampleWixExtension, Configuration: Debug Any CPU ------
D:\working\test\SampleWixExtension\SampleWixExtension\Properties\AssemblyInfo.cs(37,12): error CS0246: The type or namespace name 'AssemblyDefaultWixExtension' could not be found (are you missing a using directive or an assembly reference?)
D:\working\test\SampleWixExtension\SampleWixExtension\Properties\AssemblyInfo.cs(37,12): error CS0246: The type or namespace name 'AssemblyDefaultWixExtensionAttribute' could not be found (are you missing a using directive or an assembly reference?)
Compile complete -- 2 errors, 0 warnings
Anyone know why and how to fix it?
Btw, in the Solution Explorer I can see wix is already in References, its properties has Path of C:\Program Files (x86)\Windows Installer XML v3.5\bin\wix.dll
By adding
using Microsoft.Tools.WindowsInstallerXml;
into AssemblyInfo.cs, the project is now successfuly built.