FluentValidation exception, abstractValidator cs not found - unit-testing

I am doing UnitTest,when ever debug the method it throws exception saying AbstractValidator.cs not found, ValidationTestExtension.cs not found and i re-install the FluentValidation, fluentValidation.mvc5 but couldn't resolve,..what should i do?

Two things,
first make sure that in your controller where youre making the call for that model you have
if (ModelState.IsValid)
If that doesnt fix it, go to your solution, right click > properties, in properties check the 'Debug Source Files' and add the files to the Do not look for these source files:' section.

Related

VS2017 Debugger : has no address, possibly due to compiler optimizations

Seems not relevant to some questions with similar titles.
//some other code
std::string s = Lookup->getName().str();
-> break here //some other code
Note: "Lookup" is clang::DirectoryLookup http://clang.llvm.org/doxygen/classclang_1_1DirectoryLookup.html, "Lookup->getName()" is llvm::StringRef http://llvm.org/doxygen/classllvm_1_1StringRef.html.
When break at the above place, in the "Watch" pane in VS2017, the string variable "s" is initialized successfully and its value can be shown in "Watch" pane.
But when try to show(watch) the expression "Lookup->getName().str()" which is just how "s" is initialized, it says:
Lookup->getName().str() | Function llvm::StringRef::str has no address, possibly due to compiler optimizations.
the source code of StringRef::str() is:
/// str - Get the contents as an std::string.
LLVM_NODISCARD
std::string str() const {
if (!Data) return std::string();
return std::string(Data, Length);
}
And all the libraries is in debug version. Based on the above fact, there seems to be no reason for this to happen.
Such thing happens in other situations during debuging a Clang Libtooling program and it make debugging very hard.
What is the possible reason and how to solve it?
I tried #user15331850 solution and it didn't help, but setting Linker-> Debugging-> Generate Debug Info to "/DEBUG:FULL" seems giving me all variables now.
This may be due to optimization option is enabled.
You can disable the same by following these steps:
Right click on the solution
Click on the "properties"
From the left pane, click on the "Configuration Properties"
Click on "C/C++" from the sub-option
Then click on the "optimization" and select "Disabled(/Od)" from the list
That's it. Hope it works for you!!
I had this issue. I needed to change the settings for: Linker-> Debugging-> Generate Debug Info from "/DEBUG:FASTLINK" to "/DEBUG".

opencv\modules\core\src\persistence.cpp:2697: error: (-27) NULL or empty buffer in function cvOpenFileStorage

I am trying to run a facedetection application and I get the following error:
Unexpected Standard exception from MEX file.
What() is:..\..\..\..\opencv\modules\core\src\persistence.cpp:2697: error: (-27)
NULL or empty buffer in function cvOpenFileStorage
If you're using haarcascade_frontalface_default.xml, check the xml file content.
The first 3 lines should be:
<?xml version="1.0"?>
<!--
Stump-based 24x24 discrete(?) adaboost frontal face detector.
I inadvertently downloaded the html that linked to the haarcascade_frontalface_default.xml file instead of the xml itself and got the same error you did.
You should provide some code and information.Nevertheless the error indicates that it can not access the haarcascade file. I suggest you make sure you have the "xml" in the same folder as your code (e.g. "ViewController.mm") and check permissions. additionally Assuming you are using Objective-c or swift:
1-check the file is in your Xcode project; and, if it is,
2-check it's included in the 'Copy Bundle Resources' phase underneath your selected Target (in the project tree view on the left in the normal Xcode window layout) and, if it is,
3-look inside the generated application bundle (find your product, right click, select 'Reveal in Finder', from Finder right click on the app and select 'Show Package Contents', then look for your file in there) to make sure that it's there.
I've got the same problem, and then I figure out what's the problem
First
Add file haarcascade_frontalface_default.xml to xcode project
make sure when you add the xml file with option below:
Destination: Copy items if need [check]
Added Folder: Create Folder References [check]
Add to targets: Your Project target [check]
Second
in you Wrapper.mm file add this code to your obj-c function:
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
or in case you wanna load the xml file, use this code:
cv::CascadeClassifier classifier;
const NSString* cascadePath = [[NSBundle mainBundle]pathForResource:#"haarcascade_frontalface_default" ofType:#"xml"];
classifier.load([cascadePath UTF8String]);
this actually fixes my problem, anywaythis question has been questioned for a long time but I hope someone face this problem can come to this answer and help them solve their problem like mine, cheer.

C++ access violation: TImage.Picture is null

I recently made some minor changes within my c++-builder-project-settings to distribute a built application, however now some kind of initialisation seems to be missing.
Before I was using this (worked properly):
TPngImage *img=new TPngImage;
img->LoadFromFile(pfad);
Image1->Picture->Assign(img);
However, suddenly I get the error: access-violation... access to 0x0000000.
I checked and noticed that Image1->Picture is Null.
Image1 is of course a TImage-Object added per designer.
I'm using embarcaderos XE2 16 c++-Builder.
Is there a setting for this or could you tell me, what I have to do?
I thought of Image1->Picture=new TPicture(); already, but that is also Null...
It seems that it was my settings...
Somehow I messed some setting up.
I exported the settings of a new project, copied my include-paths, overwrote the settings with the exported one and inserted the includes.
Now everything works again.

Visual C++ - Throwing unhandled exception from setting forms icon?

I can compile the solution with no errors, but when I'll try to run it, I get a crash window:
An unhandled exception of type
'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "<myformname>.resources" was corerctly embedded or linked into assembly "<myprojectname>" at compile time, or that all the satellite assemblies required are loaded and fully signed.
And after I press Break it throws me to the line:
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
If I comment this line out, everything works just fine, but my program doesn't have icon.
Anyone else had this problem? Found a solution? I couldn't find anything clear enough for me to understand, problem is really annoying me, only solution I found was to declare my form class before any other classes, but I don't even have any other classes in my solution?
I also have only one project in this solution, ms support said something about having multiple projects, which I don't have, so it was no use either.
Take a look here :
http://www.mztools.com/articles/2005/MZ2005007.aspx
The exception is thrown because your icon cannot be located. You will probably need to compiles your resources under one .dll and put this under en-US subfolder on your project output. It did the trick for me at least. There are probably other solutions to your problem too.
Do not panic like I did. The root cause of the problem is that the compiled resource file is different from the one that is asked to load at runtime. This happens because the underlying build-script cannot detect the filename or namespace changes made after the form is created.
For example, At first we started a project named x . And our $(RootNamespace) becomes x. And we created a form named y. So our XML resource file y.resx gets compiled into x.y.resource . At this point the icon change works.
Now somehow we changed the project name or the namespace to z. But our $(RootNamespace) remains the x. While at compile-time it wrongly generates old x.y.resource, but at links-time it links z.y.resource. And at this point the icon change does not work.
It can also happen if the form is under some nested namespace which is not known in the project file.
It can be fixed by changing the compilation output of the y.resx file . It can be done by right-clicking the resource and changing the Resource Logical Name to $(RootNamespace).%(Filename).resources .
I will also make sure that ProjectName,AssemblyName and RootNamespace are the same in the .vcxproj file. Somehow if the form is declared under a nested namespace like RootNamespace.gui , then the output file of the resource should be $(RootNamespace).gui.%(Filename).resources .

ExpectedException on TestMethod Visual Studio 2010

Today I upgraded my solution with all the underlying projects from VS2008 to VS2010. Everything went well except for my unit tests.
First of all only the web projects had as target framework .NET 4. All the other projects still had .NET 3.5. I changed them all to .NET 4.
Now when I debug my unit tests it breaks on every exception. In 2008 it just wouldn't pass and tell me that an exception occurred. Even when I have the ExpectedException attribute defined it stops debugging on every exception.
And example of one of my tests:
[TestMethod]
[ExpectedException(typeof(EntityDoesNotExistException))]
public void ConstructorTest()
{
AddressType type = new AddressType(int.MaxValue);
}
The EntityDoesNotExistException is a custom exception and inherits Exception.
Edit
I looked at the Exceptions settings (ctrl+alt+e) in 2008 and 2010. In both versions the settings are the same. However in 2008 the debug doesn't break when I have the ExpectedException attribute. In 2010 it does break.
Gerrie pointed me in the right direction:
Press Ctrl-Alt-E
Open the Common Language Runtime Excepions Node
Click Add
Type Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException
Make sure that both checkboxes are unchecked.
This will get rid of the break on failed Asserts, but the test will still break when you have set an ExpectedException.
I was the one that set the 100 bonus for this, so some upvotes would be appreciated ;-)
According to Microsoft, this is not a bug, it's "by design":
http://connect.microsoft.com/VisualStudio/feedback/details/511897/expectedexception-still-causes-debugging-to-break-with-exception-was-unhandled-by-user-code
Press Ctrl+Alt+E and check the break on exception setting for CLR exceptions. If this is set to true then the behavior you described will occur.
A Microsoft support guy told me to use Ctrl-F5 (start without debugging) when running my unit tests, and that seems to work.
Another thing to try is to go to Tools|Options|Debugging
and un-check the "Enable Just My Code" option.
Make sure your reference to Microsoft.VisualStudio.QualityTools.UnitTestingFramework is Version 10.0.0.0.
If it is version 9.0.0.0 this problem will occur in Visual Studio 2010.
Hope this helps. If people still have this problem.
I second what rlandster said. Clearing the "Enable Just My Code" debugging option fixed this for me. It fixed both breaking on assers and breaking on expected exceptions. There's a little more detail on this at http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/25bdf149-5133-4f47-bbf2-1d4ca638fee9.
I've had the same issue, but finally managed to get it working. Not really sure how but here's a list of things I did between it not working to when it started working again.
Converted the project being tested to .NET 4
Turned off CodeCoverage
Turned CodeCoverage back on again
Did a RebuildAll on the test project
Not sure which bit fixed it though. Anyway, hope this helps!
I ended up changing my tests to this form to avoid the breaking. Not ideal:
[TestMethod]
public void Guid()
{
try
{
Guid g = new Guid("myguid'123'");
}
catch( FormatException fe)
{
return; // expected exception - pass
}
Assert.Fail(); // exception not thrown - fail
}