cmd vs Visual Studio - c#

I am currently working on windows application in c# and currently I met one problem.
I started to creating the windows application in notepad++ because I not able to use VS. I am using cmd to compile the code. I will add that I have one *.dll file, which is used by the application.
Now I am trying to move my code to VS. I created new solution and I used add existing item to include my code files. I also added reference to the *.dal file. I also added using namespace statment in my MainForm.cs file. Now I get problem because when I am tryind go tompile the code I got error:
The type or namespace name 'DataAccessLayer' could not be found
(are you missing a using directive or an assembly reference?)
I am wondering where I made mistake?

Original post here.
In the project properties, change the Dotnet framework from 2.0,3.0 or 3.5 to 4, compile and run!

Related

error CS0234: The type or namespace name 'Devices' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)

I am trying to go through this tutorial for on making sounds with waves using C#:
https://www.codeguru.com/dotnet/making-sounds-with-waves-using-c/
The first sample code it has you run is this, which is supposed to play a .wav file:
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.Devices;
namespace MyApp
{
class Program
{
static Audio myAudio = new Audio();
static void Main()
{
myAudio.Play("m:\\crooner2.wav",
AudioPlayMode.WaitToComplete);
}
}
}
In my code, the filepath and name of the .wav file was replaced with a different one, but otherwise the code is identical. However, I get an error regarding the second line of code: error CS0234: The type or namespace name 'Devices' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
Without the Microsoft.VisualBasic.Devices call working, I have no way of running even the first exercise in the tutorial, and definitely no way of further progressing in using C# for sound manipulation.
I was expecting the code to run and play the .wav file. However, I got the error message instead.
As part of debugging, I came across this post on the Microsoft website:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/visualbasic#types-in-microsoftvisualbasicdevices-namespace-not-available
I'm not sure what to make of it. It seems like it's saying it could be solved by upgrading to .Net 5 or higher, but I'm already using .Net 5. It also seems like it saying that Microsoft.VisualBasic.Devices was made obsolete with .Net Core 3.0, so I'm not sure how upgrading would make it easier to use something that was made obsolete.
It also says that certain functionality in Microsoft.VisualBasic.Devices has equivalent functionality that can be called by other means. It gives specific replacement calls for Microsoft.VisualBasic.Devices.Clock and Microsoft.VisualBasic.Devices.Ports, but nothing for Microsoft.VisualBasic.Devices.Audio, which is what I want to use in my code.
I have tried this in both Visual Studio and Visual Studio Code and get the same errors either way.
With .NET Core, you generally add references via NuGet packages. There is no NuGet package for Microsoft.VisualBasic.Forms.dll, which the documentation clearly states that type is declared in. To get that assembly reference, I believe that you need to replace this line in your project file:
<TargetFramework>net5.0</TargetFramework>
with these lines:
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
After doing that, you should see Microsoft.WindowsDesktop.App.WindowsForms added under Dependencies -> Frameworks in the Solution Explorer and the relevant assembly is listed under that.
You have to use reference to "Microsoft.VisualBasic" in your project.
You have two way for do that :
1st way :
Right click on project references, select "Assemblys" => "Framework" and you can search (at top right) "basic" keyword, and select "Microsoft.VisualBasic" item.
After that you can compile your project and normally its works !
Screen for add references
2nd way :
Comment or delete "using Microsoft.VisualBasic.Devices;" instruction.
The class "Audio" should be underline to red, hover with your mouse and you have option by IDE which let you "using Microsoft.VisualBasic.Devices;".
References should be automatically added in project.
And now you can compile your project.

Cannot compile C# project with gRPC

I'm trying to create a C# gRPC client for a server I have. I have the .proto file, the file's build action is set to ProtoBuf, I have created a C# class for wrapping around the client. Everything looks fine in the IDE, no red squiggly lines, everything is good.
My protobuf file's package name is controlpanel, and the IDE has no issues with the types being imported via using Controlpanel;, no issues with that, or the types that come from it in the IDE.
The .proto file is valid, as I have used it to create both a server and a client in Go.
However, the issue comes when I try to build it.
I get errors like
error CS0246: The type or namespace name 'Controlpanel' could not be found (are you missing a using directive or an assembly reference?)
I've checked the obj/ directory, and it appears the code is generated just fine.
I have no idea what the issue is, and I have searched the Internet for about an hour, finding nothing about the issue I'm having. To the point where my only 3 search results are in Chinese.
I ran into the same problem when using gRPC in a WPF application. There is an issue on Github: https://github.com/grpc/grpc/issues/18624
Workaround:
Move code generation with proto files to a regular class library. You can then reference the class library from the WPF app and use the generated types inside it.

'Sqlite' Could not be found in windows phone 8

I am working on windows phone 8
Thy type or namespace name 'SqLite' could not be found (are you missing a using directive or an assembly reference?)
My process was
I cloned git repo into my local.
I added that c++ project (Sqlite) into my existing project.
Than i added Sqlite-net ( SQLite.cs and SQLiteAsync.cs) into my project.
Than created USE_WP8_NATIVE_SQLITE compilation symbol successfully.
But than i build my project it shows same error for three lines in "SQLite.cs" which are following.
using Sqlite3 = Sqlite.Sqlite3;
using Sqlite3DatabaseHandle = Sqlite.Database;
using Sqlite3Statement = Sqlite.Statement;
Please help me to solve this problem, my VS2012 is well configured and fulfilling the requirment for creation Sqlite DB into WP8.
Need Help, Thanks in advance.
I have successfully done, i was missing the one step that was adding sqlite existing project as a reference. So after completion all steps me have to add SQLite existing project as reference in my existing project.
it worked fine.
Thank you all.

Referenced class lib doesn't seem

I have a class lib and I referenced it to another windows project. I added its namespace to my Form.cs (using SaglikNetClassLib;). they are seem unknown when I want to access to classes. I can see their properties and methods. But the complier says "Error 7 The type or namespace name 'SaglikNetClassLib' could not be found (are you missing a using directive or an assembly reference?), Do you have any suggestion?
KR,
Çağın
Are you targeting the .net Client Framework? Visual Studio let's you add references to incompatible assemblies, but then gives exactly that error.
Check your project settings to make sure you're targeting the full .net framework.
Also, check that the Ilalcar class is public and not internal (which is the default if it's only declared as class without any modifier)
You probably need an using statement to put the class into scope.
using SaglikNetClassLib;
C# won't auto suggest it if the project has not been rebuild. Also make sure the class library project has been build before using it in code.
Intellisense seems to lag behind a bit at times. Simply pressing f5 (run) sometimes rebuilds the project completely and simply runs or gives a better error message.

Namespace in Referenced Project Present in Autocomplete Before Building, but Causes Compile Error After Building

I have a class library project which uses a namespace (e.g., "Cosmos.Creator.Util"). I then create a solution and windows forms application to test the library. From the windows form application, I add a reference to the library. So now I have two projects open in visual studio, a class library and a windows forms project. The forms project references the library.
When I edit my form's code, code autocompletion works correctly for the namespace that I use in the library. E.g., if I type "using Cosmos." I get autocomplete options like "Creator". But now if I build my solution, all of the "Cosmos" are red-underlined with the compile error: "The type or namespace name "Cosmos" could not be found (are you missing a using directive or an assembly reference?)".
For the purposes of the form application test, I placed my library code into a folder CosmosFormExample\Cosmos. When I check the reference from the form application, the reference is to CosmosFormExample\Cosmos\bin\Debug\Cosmos.dll, so that looks okay. I looked at the GUID referenced in the solution file and it matches the GUID of the project file Cosmos.csproj.
What has happened? How has the build caused my forms application to forget about the Cosmos namespace, despite the fact that it is still referencing the library project? Thanks much in advance.
Are you using VS2010 & .NET 4? If so you're probably using .NET 4 Client Profile instead of full fledged .NET 4. Go to project properties and check your Target Framework.
for more info: http://msdn.microsoft.com/en-us/library/cc656912.aspx
you need to check the framework you are using and the framework yout library was compiled for...

Categories

Resources