C# name glitching/ghosting - c#

i have picBarrier as a picturebox, for some reason, i keep getting an error about a background picturebox i deleted on something, it points it out for even when its commented out. i tried deleting-text, restarting, any suggestions?
Error 1 The name 'picBackGround' does not exist in the current contex
// PictureBox[] pics = {picBarrier, picEnd, picFloor;

I'm just gonna rep whore this one.... :>
Full Clean + Rebuild fixes this. You can tell that Visual Studio is a bit out of sync with the source because it's highlighting something completely different to what it says is the issue.
Clean + Rebuild (even though Rebuild does a Clean.. sometimes its very random in what it does.. so I always suggest a Clean + Rebuild):

Related

Setting MauiSplashScreen tag on MyMauiProject.csproj with a mp4 file throw null exception from Resizetizer/SkiaSharpBitmapTools, looks hardcoded trash

Setting the MauiSplashScreen tag inside my net6.0 MyMauiProject.csproj pointing to a mp4 file makes it throw a null exception from Resizetizer/SkiaSharpBitmapTools. It looks like hardcoded trash from Microsoft. I don't even have a 'D:' drive on my machine, just 'C:', but the error points to D:\a\1\s\src\SingleProject\Resizetizer\src\SkiaSharpBitmapTools.cs:line 29 , a project I never created.
Was searching like a crazy on google, but there is nothing about it.
Even after it changes back to a gif and also changes to a svg, the error stays there.
Thinking about recreating the project and copying my source code to see if it fixes it, but I cant do it every time and that isn't a good solution.
I'm on a tight deadline project. I can't do in on Xamarin Forms because MS is discontinuing it and looks I can't do on MAUI too.
Severity Code Description Project File Line Suppression State
Error MAUI0000 System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Maui.Resizetizer.SkiaSharpBitmapTools.GetOriginalSize() in D:\a\1\s\src\SingleProject\Resizetizer\src\SkiaSharpBitmapTools.cs:line 29
at Microsoft.Maui.Resizetizer.SkiaSharpTools.Resize(DpiPath dpi, String destination) in D:\a\1\s\src\SingleProject\Resizetizer\src\SkiaSharpTools.cs:line 47
at Microsoft.Maui.Resizetizer.Resizer.Resize(DpiPath dpi, String inputsFile) in D:\a\1\s\src\SingleProject\Resizetizer\src\Resizer.cs:line 101
at Microsoft.Maui.Resizetizer.ResizetizeImages.ProcessImageResize(ResizeImageInfo img, DpiPath[] dpis, ConcurrentBag`1 resizedImages) in D:\a\1\s\src\SingleProject\Resizetizer\src\ResizetizeImages.cs:line 172
at Microsoft.Maui.Resizetizer.ResizetizeImages.<>c__DisplayClass26_0.<ExecuteAsync>b__0(ResizeImageInfo img) in D:\a\1\s\src\SingleProject\Resizetizer\src\ResizetizeImages.cs:line 88
at Microsoft.Maui.Resizetizer.AsyncTaskExtensions.<>c__DisplayClass0_0`1.<ParallelForEach>b__0(TSource s) in D:\a\1\s\src\SingleProject\Resizetizer\src\AsyncTaskExtensions.cs:line 21 MyMauiProject C:\Users\MySelf\.nuget\packages\microsoft.maui.resizetizer.sdk\6.0.101-preview.11.2349\build\Microsoft.Maui.Resizetizer.Sdk.targets 463
When clicking on the error, the IDE points to:
<!-- Resize the images -->
<ResizetizeImages
PlatformType="$(ResizetizerPlatformType)"
IntermediateOutputPath="$(_MauiIntermediateImages)"
InputsFile="$(_ResizetizerInputsFile)"
Images="#(MauiImage->Distinct())">
</ResizetizeImages>
I never ever touched on this block.
Closing and opening Visual Studio/Project doesnt fix it either.
It looks like it's pointing to here.
I had exactly the same issue. The problem was that I had a non-image file (ie a file called list.txt) in the Resources/Images folder.
Removing the file fixed the issue and the code ran correctly.
Another person had a related error here, the solution was reinstall all environment.
I Think you realized the error isnt with your code but with: C:\Users\MySelf\.nuget\packages\microsoft.maui.resizetizer.sdk\6.0.101-preview.11.2349

Visual Studio 2019 IntelliSense changed (how to get prior behavior?)

Since I switched to VS 2019 (from 2017) I am pretty sure I got a degraded IntelliSense experience. I looked for settings under Tools -> Options... but did not find anything helpful.
The matter is this: suppose I have a variable kvp that has a property Key, I could type "key.", scroll to the "Key" property (if this is not already selected) and then type ";" to complete the statement.
But this does not work anymore. Instead it now ignores what I selected and I get
key.;
The only way to get the selected property is to explicitly hit enter. Same when I type the first character(s) to select the desired option: when pressing ; it just leaves what I already typed and adds the ; immediately behind it, ignoring what I selected in the popup menu.
What happened and how do I get the proper behavior back?
I am using the Preview version but I already had a couple of updates and it does not improve so I guess it is by design or default behavior now.
Here's some of my code for Perry. It is just an example though, the problem (or what I regard to be a problem) occurs with any object variable.
private static void AddBlockNodes(TreeNode node, IDictionary<string, Block> blocks)
{
foreach (KeyValuePair<string, Block> kvp in blocks)
{
string name = kvp.Key;
Block block = kvp.Value;
TreeNode childNode = new TreeNode(name);
childNode.Tag = block;
node.Nodes.Add(childNode);
AddBlockNodes(childNode, block.Subblocks);
}
}
it just leaves what I already typed and adds the ; immediately behind
it, ignoring what I selected in the popup menu.What happened and how
do I get the proper behavior back?
It is quite an abnormal behavior and l have installed Visual Studio 16.6.0 Preview 2.1 and test your code in my side and it works well.
Type variable kvp. and then select property Key and it types as expected. I did not face missing property Key during the process.
You can try these steps to troubleshoot your issue:
Suggestion
1) reset all settings by Tools-->Import and Export Settings-->Reset all settings
2) close VS Instance, enter the project path and delete .vs hidden folder which stores some Intellisense settings, bin, obj folder and then restart your project again. I wonder if you migrate an old project into VS2019 preview version, I think you should complete this step.
3) disable any third party extensions if you have under Extensions-->Manage Extensions in case they cause this behavior.
4) delete all component caches under C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\16.0_xxx(16.0 is VS2019)\ComponentModelCache
5) try to create a new project in VS2019 Preview version and test whether this issue persists in the new platform and if it works, I think it is an issue of your project itself. Or you can try to migrate your project into the new project.
Hope it could help you.

Android/Xamarin/C#: Resource Id not constant anymore

I used to work on an Android/Xamarin project for Android 4.4, API Level 19 that contains an activity with the following code:
private void RadioButtonClick(object sender, EventArgs e)
{
RadioButton rb = (RadioButton)sender;
switch (rb.Id)
{
case Resource.Id.radioButton1:
...
The last time I looked at the project a couple of month ago, this used to work just fine. Now I want to continue working on the project for Android 8.0, API Level 26, but when I opened it in Visual Studio 2017 I got the compiler error (field)int ResourceId.RadioButton1 A constant value is expected.
Now this is not a problem in itself, as I can always use if (rb.Id == ...) instead of switch/case, but I would like to know why all of a sudden Resource.Id.radioButton1 is not recognized as a constant anymore, even though it is declared as such in Resource.Designer.cs:
public const int radioButton1 = 2131165244;
Has anyone else encountered something similar?
EDIT: Even stranger is that the project builds without complaint, but deployment is not possible due to the said error.
EDIT: It seems that the build process generates another Resource.Designer.cs file which is put into a folder obj\Debug\designtime. Once the file exists, the activities source code refers for the Id declarations to this new file and not to the original Resource.Designer.cs in the Resources folder.
However, all Ids in the new file are static and not const (which of course is the reason for the compiler error that prompted this question in the first place) and moreover they are all set to zero.
Are there any Android/Xamarin experts out there who can explain what is going on here? Might that even be a bug in Visual Studio 2017/Xamarin?
EDIT: Here is a link shedding some light on this topic: https://forums.xamarin.com/discussion/19369/compiling-resource-ids-static-vs-const
What I don't get is this: Why did the above code work at all considering that this problem is known since 2014?

0x3 error using pdbstr (Source indexing)

I am trying to use the PDBSTR.EXE tool to merge version information into a PDB file and from time to time I encounter the following error:
[result: error 0x3 opening K:\dev\main\bin\mypdbfile.pdb] <- can be a different PDB file.
An example of the command line that I use is:
pdbstr.exe -w -s:srcsrv -p:K:\dev\main\bin\mypdbfile.pdb -i:C:\Users\username\AppData\Local\Temp\tmp517B.stream
Could you tell me what would cause error code 0x3?
If the error code is similar to the standard System error code 3 ERROR_PATH_NOT_FOUND, then it seems to think that the path K:\dev\main\bin\mypdbfile.pdb does NOT exist when in fact it DOES.
However please note that my K: drive is a SUBST'ed drive.
(System error code reference https://msdn.microsoft.com/en-ca/library/windows/desktop/ms681382(v=vs.85).aspx)
Do you know what the 0x3 error code could possibly mean?
If this error code appears from time to time, then i guess the ERROR_PATH_NOT_FOUND might be the real problem.
I guess the cause is, i couldn't see any double quotes wrapping the path you've given as input. When the path contains a folder name with spaces in it, it breaks your path. For ex
pdbstr.exe -w -s:srcsrv -p:K:\dev\main\my folder with spaces\mypdbfile.pdb -i:C:\Users\username\AppData\Local\Temp\tmp517B.stream
Add a double quote around the path and that might solve it. Hope it helps.

Cannot locate resource

I don't know exactly if it is a bug but i am getting all the time runtime IOException error saying Cannot locate resource.
I am loading some images in my app (c#, WPF) in canvas background depends on database state.
The problem is, that i cannot load LAST (alphabeting sorted) file. I have for example 15 images in folder. I can load 14 first without problems. But the last one all the time throw exception.
I am 100% sure, that i HAVE the image in the folder (see !image-printscreen below).
And how i wrote. 14 first i can load without any problem, only the last one throw exception.
Is it a bug in WPF-c# or am I doing something wrong?
code what is throwing exception:
canvas_status.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), #"Images\" + statusName + ".png")));
canvas_name.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), #"Images\" + statusName + bulheadName + ".png")));
error:
IOException was unhalded
Cannot locate resource 'view/images/panel_uzavreno_d.png'.
image (for higher resolution click on image right mouse button and click on SHOW IMAGE or something like that):
I've had a similar issue: IOException, cannot locate a png resource which indeed existed in the assembly.
I found the solution by explicitly specifying the assembly name, even though the caller was in the same assembly as the resource.
Here's how it looks with a Pack URI syntax:
pack://application:,,,/MyAssemblyName;component/MyResourcesFolder/MyImage.png
(For more about Pack URIs see http://msdn.microsoft.com/en-us/library/aa970069.aspx)
Edit: One more thing I had to do after specifying the assembly name was to Clean the project. The problem returns after build but was resolved after cleaning the intermediate products. This is definitely a bug in Visual Studio.
You need to set the build action of the image to the type 'Resource'.
Right-mouse click on the file >> Properties >> set 'Build Action' to 'Resource'

Categories

Resources