So i decided to try Visual Studio 2012 professional. After installing it and opening my MVC3 solution I get null reference exception at ((WebViewPage)WebPageContext.Current.Page).Html; where WebPageContext.Current is null. Bad think is: even after checking out "clean" solution and opening it with Visual Studio 2010 I still get same exception while other project members don't. The place where exception occurs is featured in this post. Code:
// Workaround - exposes the MVC HtmlHelper instead of the normal helper
public static new HtmlHelper<object> Html
{
get { return ((WebViewPage)WebPageContext.Current.Page).Html; }
}
Related
Microsoft Visual Studio Community 2019 Version 16.8.4.
This is a CLR Project (.NET Framework 4.5).
I'm not sure about the origin of this bug, so I cannot fill in a bug report to its respective program.
I either found a bug on Visual Studio Community 2019 or AxWMPLib::AxWindowsMediaPlayer. When adding a custom control derived from AxWMPLib::AxWindowsMediaPlayer in the Designer, if you switch the Language of the form by the Designer then it gets all blank and you are forced to close the Designer. For another custom controls like derived from System::Windows::Forms::* that bug doesn't happen.
This is my ClassLibrary1.dll e.g:
#pragma once
using namespace System;
namespace ClassLibrary1 {
[System::ComponentModel::ToolboxItem(true)]
public ref class MyMediaPlayer : public AxWMPLib::AxWindowsMediaPlayer
{
public:
MyMediaPlayer() {}
};
}
Problem solved on version 16.8.6. So it was actually a Visual Studio bug.
public override string teststr => "test";
This code works fine in Visual studio 2015 and VS2017 but throws the following error in Visual Studio 2013:
; expected
That's an expression bodied property - they are only supported in C# 6.0 or higher.
VS2013 doesn't support C# 6.0 by default, so it won't be able to compile that code.
This answer discusses how to add support for C# 6.0 to VS2013. But is you're using expression bodied properties you really should learn about them more, and what language versions support them.
The expression bodied syntax is equivalent to:
public override string teststr
{
get
{
return "test";
}
}
for earlier versions of C#.
I am writing getter function in my typescript classes in visual studio. I like getter function because I feel it cleans up my code, there is one situation I want to fix though.
class Foo {
doWork(){
console.log(this.bar);
this.bar = 2;
}
get bar(){
return 1;
}
}
the first line in doWork is correct and there is no complaints from visual studio. Its the second line that I want to fix. When the code is transpiled it throws an error in the client like it should but visual studio doesnt know to complain and underline the second line. I was wondering if there was some visual studio setting that could get it to say that the second line is incorrect
This bug was solved in TypeScript version 2.0. For more insformations read TypeScript's GitHub issue https://github.com/Microsoft/TypeScript/issues/12.
You need to upgrade your TypeScript compiler. Download new TypeScript installer from http://www.typescriptlang.org/index.html#download-links (Visual Studio 2015 link) and just install.
I just upgraded my VS2013, and the same code has a different behavior in debug mode.
In VS2013, I was having the debug breaking on exception I got.
Some of them that might happens and are handled were put in Try-catch block with a DebuggerStepTrough:
Example:
[DebuggerStepThrough]
private void DoSomething(){
try{
throw new InvalidOperationException();//Obviously in my case, it's not a throw exception here but a method
}catch(InvalidOperationException){
//log something & handling this case
}
}
private void SomeEntryPoint(){
DoSomething();//In VS2015 I got the debug breaking here. In VS2013 I don't
}
I was not having this behavior in VS2013. Is there a way to avoid it?
(I've the "Just My Code" enabled)
You are correct, the behavior you described is a result of a new performance improvement that was introduced in the Visual Studio 2015. The new feature greatly reduces debugging overhead of processing clr exceptions thrown and caught within non-user modules (With Just My Code enabled).
Unfortunately, in an oversight, exceptions thrown and caught within functions with [DebuggerHidden], [DebuggerNonUserCode], and/or [DebuggerStepThrough] attributes are no longer treated as if they were thrown and caught within non-user code - the debugger essentially ignores those attributes with regard to exceptions in Visual Studio 2015 (Step filtering and Call stack filtering still work the same as they did in Visual Studio 2013).
The bad news is that there is no good way to restore the previous version's behavior for this scenario. There are 2 possible options:
Target your application to use .net framework version < 4.0
Refactor your code such that the functions/classes with those debugger attributes are in a different module and build that module optimized and/or without symbols.
The good news is that the Visual Studio debugger team has acknowledged the issue and will provide a workaround in the next update for Visual Studio 2015.
Update
The workaround for this issue is available in Visual Studio 2015 Update 2 and is detailed in the Using the DebuggerNonUserCode Attribute in Visual Studio 2015 blog post.
For those who just want to know what to do. Run the following in a command prompt:
reg add HKCU\Software\Microsoft\VisualStudio\14.0_Config\Debugger\Engine /v AlwaysEnableExceptionCallbacksOutsideMyCode /t REG_DWORD /d 1
I am encountering a weird problem. Though I am using Visual Studio 2010 and targeting .Net 4.0 in my project, I keep receiver this error from the compiler "Default parameter specifiers are not permitted" for the following line of code:
public object GetContractCompSett(string compID, bool calcItemRoot = false, bool isSale = true)
{
....
}
While searching on the web (and on stackoverflow), the solutions point to the fact that name parameters and default value are a features of .Net 4 (the error is raised when targeting .Net 3.5 and below). But in my case, my compiler is set for .Net 4.0 still I receive this error. (I have spent the whole day trying to fix it....)
Thanks in advance for any hint.
Try switching your target framework to 3.5 then back to 4. That worked here and here.