xsp npgsql C#.aspx - c#

Running: on bsd unix in a controlled environment with matching builds.
Running: xsp4 --port 8022 --nonstop --verbose
This works perfectly with C# until I add using npgsql; to the C# program:
Compiler Error Message: CS0246: The type or namespace name `Npgsql' could not be found. Are you missing a using directive or an assembly reference?
Note: I can create and run a mono program no errors with this directive:
mcs -r:/sdf/sys/pkg6_amd64/lib/mono/4.0/Npgsql -r:System.Data Npgsql1.cs
I have tried the npgsql and mono web site, stack overflow, google. Please suggest how to start xsp4 so npgsql can be found.

I checked the error web page "'Npgsql' could not be found."
There was a link to compiler options and the second link one was
libs=myhomepage/bin
I copied the Npgsql.dll into that bin directory and it worked perfectly.
David

Related

The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)

Main Problem
The above is just one of over 1k+ errors in my C# project. I am using a 2017 MacBook Pro with Catalina 10.15.6. and VSCode. The dotnet-SDK I have is 3.1.401. I tried uninstalling and re-installing it but that didn't work. I had a project that was working perfectly then last night I did brew upgrade and today I have all of these errors. Of course I tried dotnet restore dotnet ef database update Those commands succeed in reinstalling the packages to the project directory and re-applying the database migrations (this project uses a postgres database in case that's important), but it still has all of those errors.
I was able to get the project working on Firefox after I re-created a new development SSL certificate.
When I tried to run the app and connect to `https://localhost:5001" like I always do I got this
"Secure Connection Failed
An error occurred during a connection to localhost:5001. PR_END_OF_FILE_ERROR
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem."
I fixed this with the following commands dotnet dev-certs https --clean and then dotnet dev-certs https And then it started to work fine on Firefox but I still got those 1k+ errors in VScode.
In Conclusion
The project works, I just have a ton of errors in VSCode and I'm not sure what's causing them.
Error Samples
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
The type 'Task' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
I had the same issue and the way to solve it for me was:
Install Nuget package Microsoft.AspNetCore.Mvc.RazorPages ( https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.RazorPages/ )
from .net CLI:
dotnet add package Microsoft.AspNetCore.Mvc.RazorPages --version 2.2.5
Change your .csproj file, you have to add AddRazorSupportForMvc, so that it would look like this:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
The main issue is that Microsoft.AspNetCore.MVC namespace no longer exists.
Please try
dotnet dev-certs https --trust
https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx
The problem was fixed here: https://github.com/OmniSharp/omnisharp-vscode/issues/3990
When my dotnet core sdk updated to 3.1.401 it made it so that I had to change a setting in vscode involving mono.
I went to File > Preferences > Settings then searched "omnisharp use global mono" and changed the resulting value from "auto" to "never." This stopped the errors when linting.
I would like to add that while debugging this issue in your app, look for any occurrence of MVC. I ran into this issue in a Blazor WebAssembly app on .net 5, and discovered the problem was a seemingly innocuous SelectList property, which sits within the Mvc.Rendering namespace, in my shared class library assembly...

How do I add json assembly to compile C# code on ubuntu terminal using mcs?

Command line:
mcs -out:Test.exe *.cs
Error:
error cs0246: The type or namespace name 'Newtonsoft' could not be found. Are you missing an assemly reference
I have tried to compile a C# code that has line - " using Newtonsoft.Json; ",
because I want to use JSON commands inside, from that I know, I have to install JSON files or add it to the project. Yea, in Microsoft Visual Studio i would have just add it to the project and it's working. My question is how do I do that on Ubuntu using Terminal only? I have installed mono-complete. (To be exact - VPS, so I can compile a code anytime on my phone.) Code is for learning purposes. I just want to know how do I make the JSON repository/assembly or whatever it's called working using mcs command.

CSC with C# Command For MySQL

I am still learning c# and have been following a tutorial where I use Visual Studio to connect MySQL. I want to compile the file using csc on the command line this time and error cs0246 came out6 where its ays "The type or namespace name 'MySqlConnection' could not be found (are you missing a using directive or assembly reference?)".
I am just using the command "csc MyFile.cs". I know that I should be using some form of directive but I'm not sure how to use it? In Visual Studio, all I have to do is add the MySql.Data and MySql.Data.Entity into the Reference under the project. How do I use the csc command?
csc /? contains all answers... Also covered in Working with the C# 2.0 Command Line Compiler.
Will be something like (not sure what is the name/path of assembly you need to link):
csc /reference:MySqlConnection.dll MyFile.cs

How to reference System.Threading.Tasks, MySql and MysqlConnection with Mono

I am trying to run a C# console application on my server which is running Ubuntu Server 12.04. I have installed Mono JIT version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2) and additional packages like gmcs and MonoDevelop. The file that I am trying to execute is called Program.cs and when I run the command $gmcs Program.cs I get the following errors:
error CS0234: The type or namspace name 'Tasks' does not exist in the namespace 'system.Threading'. Are you missing assembly reference?
error CS0246: The type or namespace name 'MySql' could not be found. Are you missing a using directive or an assembly reference?
error CS0246: The type or namespace name 'MySqlConnection' could not be found. Are you missing a using directive or an assembly reference?
I have researched into referencing the .dll files for the above namespaces but have not been able to find an answer that is clear. Most forum links suggest that I install mono - trunk, but I want to know if I should uninstall the existing mono package and then install mono-trunk.
I am new to the Unix platform and researching every step of my way. Your help will be much appreciated.
If you are compiling from the command line, you will need to pass the referenced assemblies as a series of /r or /pkg switches, such as:
mcs /r:MySql.Data.dll Program.cs
Obviously you will need to have the required assemblies installed too.
Also note that gmcs is an (old) alias for the .net 2.0 compiler, that's why it doesn't see System.Threading.Tasks (which is a .net 4 feature). See the -sdk switch of mcs.
You should probably install monodevelop to have a user-friendly IDE to help you.

Why can't the type or namespace be found on IIS 7 server when it works fine on the local machine?

I am using DynamicPDF creator, Visual Studio 2010, and IIS 7.
On my local machine, the line "using ceTe.DynamicPDF;" and subsequent lines work fine, but
when I try to load the page on my server, I get the following error:
"Compiler Error Message: CS0246: The type or namespace name 'ceTe' could not be found (are you missing a using directive or an assembly reference?)"
I have added the .dll file as a reference, and intellisense even works.
I am wondering if it is a problem with assemblies. Any ideas about what I should do to get this working on my server?
May be you lost some of dlls, you can check dll which contains ceTe. ... by dependency walker.

Categories