My project is built on Visual C++, however the version of Visual Studio im using is 2008.
I have created a Testing Project for my VC++ project.
That creates properly, however when i choose to add a Unit Test Via the Unit Test Wizard, it gives me the error "InvalidMetadataException - Unknown virtual address 0" when i try to expand the list of classes in my VC++ Project,
Anybody know why this is happening?
Also, anybody got any tutorials or sites that will tell me how to create test methods for VC++?
Hi,
As far as I know, the unit test net framework built in VS 2008 depends on assembly metadata. Thus, if your Visual C++ project has no common language support, when attempting to create a unit test project on it, the unit test framework triggers “InvalidMetadataException”, which indicates the unit test framework can’t get the metadata. To solve this issue, please bring up the project properties and change the General Setting for CLR type to be '/clr', this will allow native code to be mixed into the project.
For detail information of C++ Unit Test projects, you can refer to
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1104293&SiteID=1
For detail information of unit test, you can refer to
http://msdn2.microsoft.com/en-us/library/ms182515(vs.80).aspx
Hope this helps!
It all works now, however when i try to expand the class it shows me this message:
No classes or namespaces in this assembly.
And no methods/modules within that class shows up.
Hi,
It is because there is no managed class defined in your program.
For a native C++ class in C++/CLI, it is represented as a struct value type in the assembly’s metadata, and the members of it are not included in the metadata (You can use IL Dasm (ildasm.exe) tool to see the assembly metadata). Thus, the unit test framework ignores native C++ classes, but tries to load managed classes.
For a test, you can add a managed class to your program and try again. For example,
Code Snippet
public ref class Test
{
public:
System::Void FuncTest()
{
}
};
Hope this helps!