Dotnet3 referencing problem (probably)
-
Hello, I've been trying my hand at making my own scripts. A test script and a locator tool (displays player loc and ingame time) have been completed and are working flawlessly, using dotnet2 and dotnet3 respectively. I've started a third script, a mission in the north of the map. After translating a time-lapse function from pascal to c# and setting up some arguments for a mission blip, reloading the script with the scripthook script-reload threw an incomprehersible error, and replacing the dll with the cs file produced the following snippet of the log:
[00:03:18] [ERROR] Failed to compile Class1.cs with 9 error(s):
at line 119: 'GTA.World' does not contain a definition for 'CurrentTimeOfDay'
at line 119: 'GTA.World' does not contain a definition for 'CurrentTimeOfDay'
at line 119: 'GTA.World' does not contain a definition for 'CurrentTimeOfDay'
at line 135: 'GTA.World' does not contain a definition for 'CurrentTimeOfDay'
at line 141: 'GTA.Ped' does not contain a definition for 'IsInRange' and no extension method 'IsInRange' accepting a first argument of type 'GTA.Ped' could be found (are you missing a using directive or an assembly reference?)
at line 148: 'GTA.Ped' does not contain a definition for 'IsInRange' and no extension method 'IsInRange' accepting a first argument of type 'GTA.Ped' could be found (are you missing a using directive or an assembly reference?)
at line 149: 'GTA.Blip' does not contain a definition for 'Delete' and no extension method 'Delete' accepting a first argument of type 'GTA.Blip' could be found (are you missing a using directive or an assembly reference?)
at line 159: 'GTA.UI' does not contain a definition for 'Screen'
at line 167: 'GTA.Vehicle' does not contain a definition for 'AttachedBlip' and no extension method 'AttachedBlip' accepting a first argument of type 'GTA.Vehicle' could be found (are you missing a using directive or an assembly reference?)The script is using dotnet3, the same as the previous one (the locator), which also had most of these same functions and is working flawlessly. I'm stumped as to how is this happening. It's like GTA itself would be referencing dotnet2 -- on the account that VS does not have a problem with the script using dotnet3, builds fine, but only popping up the same errors when referencing dotnet2.
(for the record:
using dotnet3, version4.8, latest gta5, latest scripthookvdotnet.asi (july 22), VS22)Please, if you can, shine a light on what might I've done wrong and ask away.
-
@chris_dingus said in Dotnet3 referencing problem (probably):
does not contain a definition
The error messages are clearly telling you what your mistakes are, mistakes which would have been flagged if you were using Visual Studio rather than a plain text editor.
The objects and syntax of 2 and 3 aren't always treated similarly, so choose one or the other. Best bet is 3 because 2 is no longer supported. If a property or method isn't defined, find the proper one, one that exists.
Using Visual Studio and intellisense will help you write valid code. If code doesn't compile with VS, you can't expect it to work at run time as .cs or 3.cs.
-
Just as an example:
at line 159: 'GTA.UI' does not contain a definition for 'Screen
use the above in Visual Studio with SHVDN2 and you will see a red line underneath the code and it will not compile. A clear message it won't work.
use the same in SHVDN3 and you will not see a red line, and your code will compile successfully.
for example:
`GTA.UI.Screen.ShowSubtitle("This works in SHVDN3 but will be an error in SHVDN2.", 5000);
-
-I did make it in Visual Studio. Even I'm not enough a mad man to use notepad or the like. copy-paste: "on the account that VS does not have a problem with the script using dotnet3, builds fine, but only popping up the same errors when referencing dotnet2."
-I know what the difference is between SHVDN2 and 3, I literally mentioned this in the part that goes: "A test script and a locator tool (displays player loc and ingame time) have been completed and are working flawlessly, using dotnet2 and dotnet3 respectively." I'm not misreferencing them to my knowledge: https://imgur.com/a/PRZrdrR
I feel as my messege did not go through as I've intended, if you have doubts, please question and I'll try to answer as best as I can.
-
@chris_dingus
I'm sorry I'm not a programmer and i don't understand your problem.
In my reply I answered whyat line 159: 'GTA.UI does not contain a definition for 'Screen
There shouldn't be any surprise there, same goes for your error messages because your 2 and 3 aren't the same.
All I can think of is are referencing 2 and 3 in your solution? It's one or the other.
Also are you using the extension, cs for 3? It should be 3.cs not cs.