Error while generating view in Visual Studio 2019 - c#

While I am creating an ASP.NET MVC view in Visual Studio 2019, I am getting this error:
There was an error running the selected code generator: 'the value -1 is outside the acceptable range 0,2147483647
How can I solve it?

We have to open vs-2019 and select tool -> Options-> General -> ignore GPU memory access exception if the data written didn't change. Mark it as checked then error will be disappear.

I ran into the same problem tomorrow, tried many manipulations found on different subjects, including yours, nothing worked. Finally, someone gave me a "solution" that let me continue my project, hence I'm sharing it here in case yours doesn't fit someone's issue: simply copy/paste any view...!
Yeah, it doesn't make the resilient error go away, and you'll have to hand code each new view, but at least you'll be able to keep coding your project.
Hope this helps.

You might want to check out my answer to this in:
the value -1 is outside the acceptable range of [0,2147483647]. Parameter name: value

Related

C# Visual Studio Debug DoDragDrop causes Win32 Exception clipboard format registration did not suceed

So I've been trying to pass Tuple data types in the DoDragDrop method of a winforms control. This does not appear to possible. I do get a Win32 Exception saying that clipboard was unable to register the format. It works fine with other datatypes which are not Tuple.
Is there any way to pass a tuple in a DataObject?
This applies to both normal Tuples and Value Tuples.
This does not happen with every Tuple .... Currently the following has been observed:
Tuple<RefType, RefType> does not work
Tuple<RefType, baseType> does work
Tuple<RefType> does work
Tuple<object, object> does work
This appears to be somewhat specific to my project as I am currently unable to make a minimal example that shows the same behaviour ...
Apparently its specific to the solution. I did make a minimal test project in the solution the error appears in and made it an independent project that starts up by itself. The error happens. If I reference that project in a different solution and run it, the error does not happen.
The error also only happens in Debug mode. If I run the application outside of Visual Studio it does not happen.
It turned out that this had nothing to do with DoDragDrop or Tuples in the end.
Deleting the .vs folder inside the solution made the error go away. Apparently something was misconfigured/broken inside there. No clue what however.
You might try this if you run into a similar problem

Visual Studio 2013 catching unhandled exceptions

Some days ago our new Visual Studio 2013 copy was sent to us.
I was working with 2010 before, and after working with 2013 for a couple of days, I really like it, but now I've found something really annoying. Have a look:
Well, my Visual Studio is in german language, but I think you can get what is happening.
What I am wondering is why VS says I've got an unhandled exception. What other than putting a try catch around this I can do to handle the exception?
This is just an example. My real code is a bit more complex, and the try/catch is located some levels above this piece of code.
I can not remember VS2010 behaving like this.
I had a look in the exceptions settings, but I did not change anything there, so I'm using default settings:
What I am wondering is why VS deals with this code as if it were unhandled, when as you can see it is not. That's why I do not want to change anything in my exceptions settings. Do you have any ideas or suggestions?
It's helping you. At runtime you would get the expected result ie. it will go to the catch block.
Disable all exceptions in the options and VS will ignore all your exceptions and let the code catch them.
EDIT :
You should expand the lists as they will contain checked items even if the parent/group checkbox is unchecked.
so i tried Alex his hint, to uncheck the Exception in the dialog.
After unchecking the Exception my code acted like it runs outside the VS debugger.
But i was not happy with the statement
The setting is 'global'. It will ignore the exception from then onwards
So I went on with some researches.
I put some unhandled IOException throwing in my code. VS broke at the line of throwing the exception, what i was wondering about, because i unchecked the said point. Watching VS dialogs i figured out that they were not completly the same, they have a smal difference.
One said (as my VS is in german i transalted it to english by myself, maybe the text is quite a bit different in real): IOException was not handled - this is the unhandled IOException after unchecking the item at the Exception dialog.
The other said (translated by myself again): IOException was not handled by usercode - this while the item is checked in Exception-dialog.
So what is the difference between code and usercode?
I went to google for some research, i found two very importand sites. First explains the meaning of the ExceptionDialog. I do not quote anything, because all informations on this site are notable.
ExceptionDialog explained
Now let us know how VS is detecting usercode. Therefore i found the secound site:
usercode
With all these informations i did these experiments:
Delte .pdb file of the dll containing activateCommunication() -> VS did not break
Put pdb back again, unchecked "Enable the Visual Studio hosting process" -> VS did not break
Well, it is a bit more clear now. What i am still wondering is why with hosting process enabled, VS breaks, even if i have handling code. Maybe there is some debugCode around calling my method that might be seen as the "system code" mentioned on website one!?!?
Well, thats what i found out.
Greetings
Ronny

visual studio 2008 save or backup exceptions to break on

Hi i have break on unhandled exceptions turned on, and turn off the ones i expect to happen as part of my code.
But every so often (usually on restarts visual studio resets all my Debug->Exceptions to all unselected
I want to backup these values, or manually copy the file so i can put it back rather than having to go through and reselect the ones i want.
Does anyone know how to do this?
I have tried to find answers on stack overflow already, and cannot find any, i have search google and also come up empty, i am really stuck
The way i have got round this is by upgrading to VS2010 or VS2012, as the export settings saves the exceptions list, which vs2008 didn't seem to do that.

Visual Studio Watch window not taking into account usings

I have the following code in a view model:
public Point Location
{
get
{
var rangePixels = Range * PixelsPerMile;
var xCoordinate = OwnLocation.X * MapScale + rangePixels * Math.Cos(Theta);
var yCoordinate = OwnLocation.Y * MapScale - rangePixels * Math.Sin(Theta);
return new Point(xCoordinate, yCoordinate);
}
}
One of the usings at the top of the code file is System, which contains Math.
If I view Math.Sin(Theta) in the Watch window (by selecting the code, right clicking, and choosing "Add Watch"), I get the following error:
The name 'Math' does not exist in the current context
What I want to know is:
Is this expected/default behavior for Visual Studio 2010? I could swear this never used to be a problem, but maybe it's always worked that way and I somehow never noticed.
If it's not normal to get this error, any thoughts on what the problem could be? There are a million settings in Visual Studio, and I wouldn't know where to begin.
I should note this question is vaguely similar to this, but I'm not having any issues mousing over my local variables, and I'm not using PostSharp.
Edit
I just tried resetting all my Visual Studio settings backs to default, and I'm still getting the same error. If someone wants to try a simple test in Visual Studio, I just want to know if you get an error if you add a watch for Math.Sin(1).
Edit 2
Here are a couple screen captures to show what I'm experiencing:
Edit 3
Interestingly, intellisense works if I type Math. into the Watch window, but if I complete the expression, I still get the error:
Edit 4
To address BACON's questions:
I get the same behavior with QuickWatch and Immediate.
Closing and reopening all the windows does not solve the problem.
I'm using Visual Studio 2010 Professional (version 10.0.40219.1 SP1Rel)
I tried targeting .NET 4.0 Client Profile and full .NET 4.0. Made no difference. I created a Console App (rather than a WPF app) targeting .NET 4.0 Client Profile, and finally, the error did not occur. So, WPF may be an issue (or WPF with some third-party libraries). (Will check on that next.)
It appears that the culprit is a third-party library that performs IL weaving (Fody.PropertyChanged).
If I create a new WPF project without this library, I'm able to use Math.Sin() in the Watch window. Once I install PropertyChanged, I start getting the "not available in this context" error.
Thanks to #BACON for leading me down the right path to figuring this out.
Here's a link to an issue I posted on the PropertyChanged site:
http://code.google.com/p/propertychanged/issues/detail?id=6&thanks=6&ts=1330494634
Edit
And subsequently, it turns out this is probably a bug in Mono-Cecil, which PropertyChanged uses:
https://github.com/jbevain/cecil/issues/90
I did this in a litte test app, in the constructor..
Trying to put a watch on Math lets me see the values of E and PI.
You cannot put one on Sin.
Putting one on val works just fine.
So, no, I don't think that it's quite normal, unless you clicked on the wrong name. I.e., not the variable, but the "Sin" portion...
Here is where I highlighted the entire thing...

VS 2005 Compile on Save C#

This is baffling me, I am unable to find this setting if it exists.
I am 90% sure that my code used to compile on save before.
I only started having this issue when using C#, .net worked fine.
But now I am only able to get rid of error lines etc, when choosing to enter debug mode.
For example when I have a method
public bool Method1(){
//No code added yet so I get a blue line saying return something
}
Even when I add what to return inside the method the line remains there on save. It only goes away when I build.
(This is just one example it seems to happen with lots of other things)
EDIT - In regards to options to compile on save.
The options in Build and Run are set Correctly
That should produce a red underline and an entry in the Error List window: "not all code paths return a value". It is produced by the IntelliSense parser, not the compiler. Saving the file does not remove the error hint, only opening another project does. And fixing the code of course.
There is a bug of sorts in this logic, in some cases the Error List doesn't get purged. The only workaround I've seen is to restart Visual Studio. I've only seen this with certain IntelliSense warnings and it only affects the Error List, not the editor. I can't remember the exact type of warning that triggers this, it only ever happened when opening a project with code I didn't write. These messages don't normally last long when I'm editing code. Which is by far the best solution.
Should it not be the other way around? Save on compile.
Anyway, you can simple change the ctrl+s key combination to build and save in the settings menu.

Categories

Resources