So just to clarify a point. This is not something that we officially support. I know we do not have the NI-Reports functionality in the .NET libraries. I'll file a suggestion for this to be evaluated for future releases. A workaround would be to use the Primary Interop Assembly that Microsoft provides for MS Office, or basically wrap the NI-Reports C++ API in a managed layer, like you are doing.
With that out of the way, here is a project I was playing around with. Here is what I did.
I started with a standard managed C++ class library project. I added MFC support to it by checking out this link
here and then modified the project to fix the mixed-dll loading problem from
here. This mixed dll problem is an important one, so I suggest checking this one carefully. Otherwise you get weird errors that dont make sense. The wizard that the guy has on code project didnt work so I had to copy and paste some stuff manually. And change some project settings.
Once I have included MFC support, I was able to use the Measurement Studio Add/Remove Components Wizard (the little MStudio icon that shows up on the toolbar) to add the NI-REports classes to my project. From there on, it was just walking thru the document I referenced. The Components wizards didn the hard part about adding all the correct libraries. I'm attaching the wrapper project here. You can better decide how to want to design the wrapper, but I suggest using the
Dispose pattern for cleaning up, since this is recommneded by Microsoft, especailly when dealing with unmanaged resources.
To use the class from C#, I had the following
private void button1_Click(object sender, System.EventArgs e)
{
Class1.InitializeReports();
Class1 test = new Class1();
test.Printing();
test.Dispose();
return;
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Class1.TerminateReports();
}
Hope this helps. Best of luck with your project.
Bilal Durrani
NI