I have a C# code base that uses GitVersion.MsBuild. Sometimes my Jenkins build server gives me this error:
GitVersion.BugException: GitVersion has a bug, your HEAD has moved after repo normalisation.
To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
This often happens when building a feature branch that is not based on the latest master (i.e., master has moved since the feature branch was made).
The error message describes a suggested fix/workaround, but I am hesitant to do this because I don't know what environmental variable IGNORE_NORMALISATION_GIT_HEAD_MOVE does, and I cannot find a description of it anywhere.
If I set IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1, what side effects does this have?
Thanks in advance!
EDIT: I asked the same question in an issue on GitVersion's GitHub.
According to the maintainers of GitVersion, this variable just suppresses a BugException that otherwise gets throw in this situation.
See issue here: https://github.com/GitTools/GitVersion/issues/2934
Related
Since I pull my project from GitHub and attempt to run my app the problem keep happening when it refers to Json.net when trying to serialize anything. Originally it was at version 11 when the error showed up, then I tried to downgrade to version 8 and it still persists. So, I upgrade to latest on 12.0.1 but the problem still not going away
The code is nothing but Newtonsoft.Json.JsonConvert.SerializeObject(data)
And no matter what type of data it is it always thrown
FieldAccessException: Attempt by method
'Newtonsoft.Json.JsonSerializerSettings..cctor()' to access field
'Newtonsoft.Json.JsonSerializerSettings.DefaultContext' failed.
I even tried to construct the JsonSerializerSettings on my own and that still happens.
Will this answer help you?
Basically, in order to workaround this problem you need to make sure "Enable the Visual Studio hosting process" is unchecked in your project's settings under Debug.
This error may occur if the code is running under partial trust. Following link can help more in providing error description:
https://learn.microsoft.com/en-us/dotnet/api/system.methodaccessexception?redirectedfrom=MSDN&view=netframework-4.7.2
Previously, I have encountered this error if the code has restricted access like private, protected or internal methods. As per MSDN:
This exception is thrown in situations such as the following:
A private, protected, or internal method that would not be accessible from normal compiled code is accessed from partially
trusted code by using reflection.
A security-critical method is accessed from transparent code.
The access level of a method in a class library has changed, and one or more assemblies that reference the library have not been
recompiled.
Hi diddaly hodely neighboronies!
I am currently making a test project to make sure my project is working correctly.
All of the tests work fine except one. It finishes the test with no errors as seen below...
It then updates the Passed Tests list...
However, a few seconds later when it's done it outputs this message:
An exception occurred while invoking executor
'executor://mstestadapter/v2': Object reference not set to an instance
of an object.
And the test is no longer lit up indicating passed.
Me and a friend have been googling this all day and have found the issue on a few pages, with completely different answers, none of which solved our problem.
Has anyone else had this issue and solved it? Please share!
Turned out to be a DLL that was being executed but didn't report back errors. I doubt this will help many people, but check your references and make sure it has what it's looking for. I'm assuming this is because it's using the Test path instead of the project it's tied to. Good luck to those who are haunted by this issue.
UPDATE: Yup it was the reference issue, but it is running on a separate thread. Youch! Check your threads!
What do these three gray dots mean? I recently updated to Visual Studio 2017, and I haven't ever seen them in other versions of VS.
They indicate suggestion from Visual Studio to refactor your code to be simpler, more readable and efficient.
See Quick Actions and Refactorings section of the Visual Studio 2017 (version 15.0) Release Notes.
Just to make doubly clear for newish programmers, these are not in any sense error messages. They are merely suggestions for more "readable and efficient" code as #Oleksander states.
Some may not be the best advice for your application, unlike warning or error messages, which almost 100% are in my case at least.
I had suggestion in a Unity game engine C# application to make a variable "readonly". I'm not sure in my case it makes practical difference whether this is readonly or not, as in this case I think fairly obvious in the context: a private variable which is serialized and can be set in game's editor program, nobody likely to create new method in this game scene manager class to alter/assign this variable. Likewise it gave a suggestion to create property for a class private field, which I think extra code overkill.
At the least these are low priority messages to action.
Suppressing 3 Dot Symbols in Visual Studio
If you right click and read through one of these suggestions, you can find there is option to suppress these messages in global project file, with various optional parameters. So eg in my case, now I don't want any readonly message suggestions for whole project (welcome correct me anyone more experienced if this is bad idea!), so in the root of project, same level as .sln solution file, .csproj files, .git file in my case for C# project, it saves file called "GlobalSuppressions.cs". Root location and this exact file name is presumably crucial.
I guess if you want stop future coders / future you from fretting or spending time on these 3 dot messages when you think waste of time, could be useful.
In my case, to get rid of all "readonly" keyword suggestions in this project, code is (comments are VS auto comments):
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier")]
I have implemented SagePay payment using the Form Integration. My implementation is based on the .Net integration kit supplied by SagePay which has all been good.
Recently we have enabled 3D Secure and have encountered an issue when the value of 3DSecureStatus returns a value of NOTAVAILABLE.
It would seem that when the NOTAVAILABLE value is returned, an error is thrown within the call to the ConvertToSagePayMessage() method on the SagePayIntegration class within the assembly SagePay.IntegrationKit.DotNet.dll.
Specifically, this error occurs when the value is being parsed to the ThreeDSecureStatus enum. This enum does not have a value for NOTAVAILABLE to be able to parse to, hence the error.
I have put a fix in for this for the moment to get this working for now. This fix replaces the NOTAVAILABLE value with NONE, so this now parse to a valid enum value. This is done just before the call to ConvertToSagePayMessage()
cryptDecoded = cryptDecoded.Replace("3DSecureStatus=NOTAVAILABLE", "3DSecureStatus=NONE");
I was just wondering why the ThreeDSecureStatus enum does not have a value for NOTAVAILABLE, as NOTAVAILABLE is one of the values that it is expected to return, which is outlined in the Form Integration Protocol guide supplied by SagePay. And was hoping to implement a more robust fix, rather than the string replace.
The problem is that the integration kit contains a bug in that the enum for the 3DSecure status is missing a value for NOTAVAILABLE. SagePay have even told me this:
Unfortunately this is a known issue with the .NET kit but there is no fix as of yet.
So there are three possible ways to fix this.
Either modify the decoded response from the server to change the value of the 3DSecureStatus value to NONE (as written in the question.)
Use a version of the Integration Kit that has had the fix applied. You can ask SagePay for the code (they seem perfectly willing to provide it free of charge) and add in NOTAVAILABLE as an enum value in the ThreeDSecureStatus.cs file:
public enum ThreeDSecureStatus
{
NONE,
OK,
NOAUTH,
CANTAUTH,
NOTAUTHED,
ATTEMPTONLY,
NOTCHECKED,
INCOMPLETE,
MALFORMED,
INVALID,
ERROR,
NOTAVAILABLE //<--- Add this
}
I have already gone through the process of fixing the bug and have uploaded it to a GitHub repository. Feel free to take the code from there. I have also updated the project to use C#6 and as such you will need to use Visual Studio 2015 or higher to use it. If you do need to use an older version, you could start with the original files from the first commit to the repository.
Here is the error
Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized.
I am writing a simple console app and the first line of code is this:
List<MyObjectModel> list = MyObjectModel.GetNonCompletedReturns();
and the code for the function is:
public static List<MyObjectModel> GetNonCompletedReturns()
{
MyObject service = new MyObject();
List<MyObject> entities =
(from recs in service.Retrieve() where select recs).ToList();
List<MyObjectModel> models = new List<MyObjectModel>();
foreach (MyObject entity in entities)
{
models.Add(BindModel(entity));
}
return models;
}
and if I try to step through the code, as soon as I get back to the main of my app and hover over the list, I get the error message that I showed.
Can anyone help?
If your project is compiled in release (with optimizations turned on), you may see this. Have you tried the DEBUG configuration?
This error fires only when you are trying to use Watch dialog during debug.
Try to use some other technique to output the variables, like Debug.WriteLine, Console.WriteLine and so on.
None of the answers solved my problem so I'm posting the solution that helped me.
"If there is to much data in the parameters then this error can occure,
a simple solution is to make an object, not a struct because that's a dataobject.
Put this object in your parameters instead of all the different variables,
normally the problem will no longer take place."
Here's a little trick just in case you want to examine some objects and you are not able to change the parameters:
I've created a call to a new temporary function, inside the function from where I was unable to watch my object. Then, inside that new function I was able to watch my object. After the job is done, just delete the function.
While it's true that the "Cannot evaluate expression because a thread is stopped at a point where garbage collection is impossible, possibly because the code is optimized" error appears when in release mode, most developers just ensure that their projects are configured to compile as a debug build. BUT to be sure that you have no release-DLL issues, you also must check the references to DLLs that are in your solution and make sure that you don't have a reference to a release-build DLL. If you find that this is the case, delete the DLL reference and then add a project reference rather than a DLL reference. The project reference will ensure that your solution references debug or release versions of the DLL as specified in your build configuration.
Note that the above advice applies, of course, to only those DLLs to which you have source code and which are built from a project in your solution.
I got this too, when I hit a NullReferenceException from a 3rd party control.
In this one case, I found that if I set a breakpoint before I hit the exception, I could then single step through the rest of the code without seeing the problem.
No idea why, but this worked for me - in this case at least.
For what it's worth, this error can also be caused by an infinite loop in a property getter (simplified version below). When the debugger attempts to evaluate the property (e.g. in the watch window) the UI will hang for a few seconds and the "Cannot evaluate expression..." error will appear for many of the other properties in the same class.
public int MyProperty
{
get
{
while (true) { }
return 0;
}
}
First make sure that you're running your code in DEBUG mode and with code optimization turned off. you can turn that off from the properties of your project.
If you made all of the above and the problem persists, then it's probably a problem with the stack having Debug.Break() on top of it. The solution for this is very easy, just press F10 to move to the next line and you should be able to evaluate the expression.
You can check this SO question for more information about this issue.
I was experiencing the same error message in the Visual Studio debugger when evaluating a linq expression.
Disabling the VS debugger config setting 'Enable Just My Code' resolved the issue for me:
To enable or disable Just My Code, choose the Tools > Options menu in
Visual Studio. In the Debugging > General node, choose or clear Enable
Just My Code.
https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code
I was having same issue in Visual Studio 2017. Going to Debug> Options> Debugging> General and checking "Suppress JIT optimization on module load(Managed only)" fixed my issue