I am having problems getting the << operator to work for cout and writing to a FileStorage object in Visual studio c++ 2010 express. I am using the vs10 libraries, included the \*\*\*d.lib files and am running my project in debug mode. Other opencv functions (ORB, imshow) seem to work

When I use the << operator for printing a matrix with cout I get an access violation error. 

The second issue I am having is when I try to write a matrix to a FileStorage object. I can write 1 matrix and read it from the file without it crashing. When I however try to write 2 matrices I get an "Exception at memory location" error on the second write. The console error says that No element name has been given.

The code I used for testing:

```
cv::Mat test(3,3,CV_8UC1);
cv::FileStorage file("fudge.xml", cv::FileStorage::WRITE);  

for(int x=0;x<3;x++){
    for(int y=0;y<3;y++){
        test.at<unsigned char>(x,y) = x+y;
    }
}

std::cout<<test<<std::endl;

file << "rotMat1" << test;
file << "rotMat2" << test;

```

**Code Update**

this is my entire code 

```
#include "stdafx.h"
#include <opencv2\core\core.hpp>
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    cv::Mat test(3,3,CV_8UC1);
    cv::Mat test2(3,3,CV_8UC1);

    cv::FileStorage file("fudge.xml", cv::FileStorage::WRITE);  

    for(int x=0;x<3;x++){
        for(int y=0;y<3;y++){
            test.at<unsigned char>(x,y) = x+y;
            test2.at<unsigned char>(2-x,2-y) = x+y;
        }
    }

    std::cout<<test<<std::endl; //error 1

    file << "AAAAA" << test;
    file << "BBBBB" << test2; //error 2

    return 0;
}

```

both errors still occur

**UPDATE, I fixed it (kind of)**

I found the problem but now there is a new one. So the problem was that because I have projects in both VS2010 and VS2012. Because of this I added both vs10/bin and vs11/bin to the path variables. It turns out that this results in visual studio using vs11/bin (maybe because that was declared first). After removing the vs11/bin decleration it worked in vs2010 but now vs2012 is broken. Because this isn't part of the original problem I will set it as answered.