I am a complete beginner to Unity, as well as Visual Studio 2022.
I was trying to make a 2D game, and have been following along this tutorial, https://www.youtube.com/watch?v=7iYWpzL9GkM. At 25:11, we are shown how to make a script to control the player movement. While I was going to use Visual Studio Code, the Unity debugger for VScode is deprecated, and no longer functions.
To solve this I switched to Visual Studio 2022. I installed the 'Game Development with Unity' and the '.NET desktop development' modules, and set the default external editor within Unity to Visual Studio 2022. I also regenerated the .csproj files as I was instructed in another form.
Despite this, I encounter error CS0246: The type or namespace name 'InputValue' could not be found (27:29 in the video, I am using the 'Player Input' module from Unity)
The libraries also do not light up green, but I am not sure if that is just a theme difference between us, but this is a clean install with the default dark mode.
At 22:20 in the video they get the Input System package from the Package Manager.
The documentation for InputValue says it's from the UnityEngine.InputSystem namespace, so when you see the error:
error CS0246: The type or namespace name 'InputValue' could not be found
It's the compiler telling you it can't find the namespace where InputValue is defined.
To solve this problem, you need to add a "using" statement at the top of the file to tell the compiler where to find that function.
using UnityEngine.InputSystem;
Their code won't work without it, either and actually at 31:50 in the same video you see them realize the error and correct it as well.
Related
So I have installed an Excel Data Reader in VS's NuGet package manager. After installation everything works fine and my code run's smoothly. After I have finished coding for the night I save my work and then commit my changes to sourcetree.
The next day, I open up my project again and at the top of the form the part where I state what I'm using (I don't know what they are called I'm only a beginner, but I'll put an example of what I mean below)
using Excel;
using System;
etc. etc.
There is a red line under Excel and it says:
A 'using namespace' directive can only be applied to namespaces; Excel is not a namespace. Consider using a 'using static' directive instead.
And then further down the code when I use methods from the package it says
The type or namespace name 'IExcelDataReader' could not be found (are you missing a using directive or an assembly reference?
Or
The name 'ExcelReaderFactory' does not exist in the current context
I have tried uninstalling and reinstalling the package and using the static directive but none of it works, even though the same code was working the night before, it's just when I save it to sourcetree this happens. How do I fix it?
I installed Unity 2017 with Visual Studio 2017. I am attempting to add an external DLL to the Visual Studio project through the solution explorer. When I right click on References, the "Add Reference" option is completely missing!
I'm trying to use NpgSQL. Hence, the need to add npgsql.dll.
Can anyone give light?
The Add Reference... is in a different place in this case.
Things to do in Unity:
Create a folder named Plugins as a child to your Assets folder. (Assets\Plugins...)
Next copy your DLL to this plugins folder. You can do this using Windows Explorer or just drag it into the folder in the Unity editor, like shown:
Things to do in Visual Studio:
Click on Analyzers in your project as shown below, then click Project from your menu, then navigate to Add Reference...:
Now Browse to your DLL:
And... there it is:
Accepted Brien's answer (Thank you, Brien!).
I'm adding my own answer pertinent to Npgsql.dll, because it's apparently a common problem all over the internet with poor documentation. If you got here from google about Npgsql.dll then read on:
Unity (for some unknown reason) comes bundled with it's own npgsql.dll inside of the application mono/2_0 folder. Some people have reported conflicts with this.
Many of the npgsql.dll versions currently do not work with Unity. Attempting to include them in Unity's assets will cause Unity to throw a Type error. This is what caused me to think that I needed to add the file as a reference in C#. This is why I came here and asked the question about Add Reference. But, with Unity, this was simply wrong on my part.
As far as I can tell, Unity insists on managing all project properties and references for you. Both managed and unmanaged DLLs must be added via Unity assets. Even Visual Studio project properties cannot be changed within Visual Studio for Unity. And if you attempt to edit the .csproj files (for instance to disable compiler warnings), Unity will overwrite the .csproj files completely next time you load your Unity project.
Anyone who has problems getting Npgsql.dll to work in Unity needs to use the proper Unity workflow where you drop npgsql.dll into Unity assets. If you get errors, it's an npgsql.dll version conflict. Try other versions of the dll first.
This gentleman has provided a Unity specific build to resolve a namespace conflict (Just pull the dll from the bin folder on the Github link):
Unity NPGSQL.DLL
Unity 2017 currently allows you to change to .NET 4.6 as an experimental setting. Some people have toyed with using that setting to get newer versions of npgsql.dll to work properly, but they report intermittent results. For now, I solved my problem with Unitynpgsql.dll. It's an older build, so hopefully I won't run into any features I need that it doesn't support. If so, I'll probably just work around them.
To anyone else trying to make npgsql.dll work in Unity: do not despair, just try to resolve the version conflicts. Also here is another relevant recent thread about it:
Barebones Master Server Npgsql.dll Issue - January 2018
Summary: I'm trying to compile a NVIDIA SDK app in Visual Studio 2012 on Windows 8 and I get the error message: FXC : error X3501: 'main': entrypoint not found. I'm new to Windows programming and trying to figure out what this means.
Details:
I'm trying to compile the Multi-View Soft Shadows NVIDIA SDK app. After downloading it I had a vcproj file. I opened this in Visual Studio 2012 on Windows 8 and had some warnings during the conversion but it seemed to open the project correctly.
However, when I build the project I get the following error: FXC : error X3501: 'main': entrypoint not found.
At first I thought this might be because there is no main function in the application. But then I found the wWinMain which I guess is supposed to replace main in some Windows applications. So I think that the source code is correct, but perhaps there is some setting with Visual Studio 2012 that needs to be changed. But searching for that error message hasn't answered my question, so I'm wondering if someone can explain what the cause of the error is and any advice about how I could fix it.
This isn't a C++ problem... the shader compiler, fxc.exe, is looking in your shader code for a function called main. It isn't finding it and throws an error as a result. Right click on your HLSL files and go to Properties -> Configuration Properties -> General. There should be an Item Type field. Change it from HLSL Compiler to Does not participate in build. That should prevent the HLSL compiler from coming along and giving you those errors.
You need to change (in Project Properties -> Linker -> System -> SubSystem) the subsystem of your application from CONSOLE to WINDOWS. After that, the entry point will be changed from Standard C/C++ main to Windows-specific wWinMain.
So I've been working on a WPF project with Visual Studio 2010 for awhile. I'm using several class library projects with WPF controls that I wrote. Today I opened the solution in Blend for the first time, and it showed me many errors like this:
"the name xxx does not exist in the namespace yy"
Looking at the assembly, I can see that the class appears at that namespace. Also if it didn't, Visual Studio wouldn't have compiled it, right?
I checked similar questions, and no, I don't have the x86 build platform thing, all my DLL's are .Net 4.0, and no missing references.
Is there anything else?
Looks like some Bug in Blend. I fixed this by removing the project references and then adding it back again
I'm beginning my first explorations into Silverlight RIAs and EF4, but I can't get a project to run right off the templates that ship with VS2010 SP1.
Bear in mind here that what I've done is to install a brand new Windows 7 VM, and then I immediately installed LightSwitch Beta 2. Following that, I added VS2010 Premium, and applied Service Pack 1 to that.
The client portion of the Template app is kicking off three warnings and two errors; the details are posted below. It's looking for a WebContextBase class that it can't find, in code that it generated into Web.g.vb (and Web.g.cs) files. So far this project is entirely generated off the solution template; I haven't added a single line of code to what VS2010 generated.
I've since gotten EF4 to work fine in WinForms projects and Light Switch projects.
What's going on here, and how do I fix it?
------ Build started: Project: EF4Test, Configuration: Debug Any CPU
------ C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(21)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(22)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(23)
: warning BC40056: Namespace or type
specified in the Imports
'System.ServiceModel.DomainServices.Client.ApplicationServices'
doesn't contain any public member or
cannot be found. Make sure the
namespace or the type is defined and
contains at least one public member.
Make sure the imported element name
doesn't use any aliases.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(34)
: error BC30002: Type 'WebContextBase'
is not defined.
C:\Users\Rob\Documents\Visual Studio
2010\Projects\EF4Test\EF4Test\Generated_Code\EF4Test.Web.g.vb(65)
: error BC30451: 'WebContextBase' is
not declared. It may be inaccessible
due to its protection level.
Have a look at LightSwitch Beta 2 Readme
There are few know issues with the LightSwitch. From the steps you have described to setup your system I would guess that the problem could be because
"2.1.1 Visual Studio 2010 users or
Visual Studio 2010 SP1 Beta1 users
must install Visual Studio 2010 SP1
before installing Visual Studio
LightSwitch Beta2"
You should try uninstalling LightSwitch Beta2 and then reinstall, and let us know if you get the same error.
Hope this helps.
Include this reference..
System.ServiceModel.DomainServices.Client.ApplicationServices