How do I add a namespace inside nopcommerce? - c#

I'm using nopcommerce.
I want to get Stock qty from external data base.
So I add a another project inside Presentation folder and I set the database connection string inside the web config file.
The I try to use new project function inside the Nop.Admin project.
For that I write
using ExternalDB;
But there is error-
The type or namespace name 'ExternalDB' could not be found (are you missing a using directive or an assembly reference?)
Do you have any idea on why it can't find the namespace? How do I add a external project with a external DB inside the nopcommerce?

There's no concept of one project inside another project. You can have a project inside a solution in Visual Studio, but that's not the same thing.
You should look at which namespace the ExternalDB type is in, and just have a using directive for that namespace.

Is "ExternalDB" a project name or a type?
I guess you miss to add a reference associated with "ExternalDB" to your Admin project.

Related

Adding Global Using Directive in blazor

The type or namespace name 'XXX' does not exist in the namespace 'MyClassLibrary.Models' (are you missing an assembly reference?). The error refer to this BlazorProject\MyPager.azor.g.cs
I got this error after this scenario:
Created a file of type .cs inside my "Blazor project" and I added all my global directives by using keyword global inside this file.
Changed some namespaces in my "Class library"
Structure of the project:
Blazor-serve-side project using the class library
Class library.
When I go the page , I can't see any error, the error just in VS, I tried to clean the solution, rebuild, closing VS and reopen but it doesn't solve the problem. I am using VS22 and .Net6.
Note
I have also in my blazor project _Imports.razor file
#MisterMagoo, Thanks a lot.
what you said works fine, plus that I have to repeat the same namespaces with global directive file and also in _Imports.razor file, so the soultion:
In GlobalUsings.cs:
global using Microsoft.AspNetCore.Components;
global using Microsoft.AspNetCore.Components.Forms;
In _Imports.razor if you need the same namespaces in your razor pages, then you have to repeat them.
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
Keep in mind that the scope of "global using" isn't truly global. It's the current compilation, which typically means the current project (not the current solution). If you want to use this feature in two different projects in your solution (a Blazor Server project and a Class Library in your case, for example) you will need to create "global using" statements in both projects.

VisualStudio.Net reference not working

I create a new solution called "WordpressAutomation"
I create a new project, a class library, called "WordpressAutomation" in this solution
I create a new project, a unit test project, called WordpressTests in this solution
I add a reference to the project WordpressAutomation in the project WordpressTests"
This should be ok, shouldn't it?
However, as can be seen from the screenshot, when adding this using line in a class in the project WordpressTests,
the reference doesn't work. Even though it is there, as can plainly be seen.
When entering "using", the class library "WordpressAutomation" doesn't appear among the alternatives.
And I get this error message when trying to run:
"The type or namespace "WordpressAutomation" could not be found (are you missing a using directive or an assembly reference?)"
Why is this happening? The reference is clearly there?
http://i.stack.imgur.com/L0g5R.png
Your project isn't actually including the .cs files to compile; they are only shown for information (they should appear as solid files with the C# logo):
Right click on these files and include them in the project. Then check what namespace they declare inside them. At the moment, your WordpressAutomation project simply doesn't contain any types.

C# - using library error

I have a .dll file which is in another folder from where my project is. I add the reference to this library into my project and then when I try to use(import) it using QRlib; I get the following: The type or namespace name 'QRlib' could not be found(are you missing a using directive or an assembly reference?)
I was given the library file, so it's not me who implemented it, but I have to use it (and I am pretty sure there are no problems with it). What might be the problem ?
In solution explorer window of visual studio, expand nodes like this
project node=>"reference" node
Double click the dll name you added. This will open the object browser window where you will find all namespaces, class and methods.
Look at the lib in decompiler (dotPeek for example) and check what are the namespaces. Maybe you are using wrong namespace?

The type or namespace name 'XmlConfigurator' could not be found

The type or namespace name 'XmlConfigurator' could not be found (are you missing a using directive or an assembly reference?)
Am I missing a namespace???
You have to add log4net.dll to your project and the using log4net.Config; namespace
Your missing dll. Right click on your project and Add Reference... point to correct dll.
There is the possibility that you have not added the dll. This would require right clicking your project and adding the reference DLL. There is one other step that wasn't mentioned in the previous answers that I found relevant.
There is the possibility that you are not using the correct runtime. I found that log4net requires a full profile. For instance the client profile for .NET 4 will generate this error but if you use the full profile you will not experience this.

i got an error in login code

I tried writing a login code in vc#.. I got the following error..
The type or namespace name 'LoginControl' does not exist in the namespace 'ErikSchmidt' (are you missing an assembly reference?)
Please help me rectify this error.
This means that Login Control is not visible to your code. What you need is specify LoginControl's namespace with using keyword or add assembly reference (with login control) to your project.
.NET projects must define which assemblies they require (such as System in most C# programs). It looks like you didn't add a reference to the assembly that contains LoginControl. Right-click on "References" in the project (in "Solution Explorer") and add a reference to the required assembly (which is wherever LoginControl is contained in).

Categories

Resources