I had to create custom controls in vb.net for moving in databases in C++.net now my only problem is how do i import that dll or add it to the C++ .net project so that i can use it in any of the forms i'm using.
OK i'm doing the #using stuff but when i compile i get error C1107: could not find assembly 'DataNavigationControl.dll': please specify the assembly search path using /AI or by setting the LIBPATH enviroment variable.
If you are editing the properties for the debug build of your C++ application then you should choose the debug build of your VB application (Note: I am assuming that there is such a thing as a debug build in VB .NET - it is years since I did any VB programming) ... if you are editing the properties for the retail build of your C++ application then you want to choose the retail build of your VB application (again assuming such a thing exists).
As your custom button was built as a VB .NET assembly you don't have to include any headers files or link against any libraries. All you have to do is reference the assembly and start using the custom botton class you defined. For example:
// MyCppProject.cpp // Adding a reference to an existing assembly using the project // setting removes the need for the following line as it is added // implicitly using the /FU compiler command-line option: but having // it heres makes the example somewhat clearer #using <MyVBButton.dll>
using namespace MyVBNamespace;
public ref class MyForm : Form { public: // ... private: MyCustomButton^ button1; };
I always add a reference to the assembly in solution's debug folder.
If you use the project properties to add a reference to the assembly then you should not need to add a #using (or add /AI to the cmd-line) as the project system will set everything up correctly. You only need #using and /AI if you want access the assembly manually - and I don't suggest doing this as the project system will not know about this relationship between the projects and hence they may not be kept correctly up to date.
Robert: you need to add the VB assembly to your C++ project. There a several ways to achieve this.
The easiest way is to bring up your C++ project properties page (I usually do this by right-clicking on the project and select properties). Click on "Common Properties" and then on "References" then click on "Add New Reference..." this will bring up a dialog. If your VB control and your C++ project are both part of the same solution then I would suggest that at this point you click on the "Browse" or "Recent" tabs and navigate and select the VB assembly. Remember to match debug to debug and release to release.
If i dont use the #using and AI/ i get undefined Identifer and all that other stuff that comes along with it. by the way i dont know if i said im using the VS .net 2005 Beta 2
importing VB.net dll (controls) into C++ .net
Sara Tahir
Girish BK
klaser123
As your custom button was built as a VB .NET assembly you don't have to include any headers files or link against any libraries. All you have to do is reference the assembly and start using the custom botton class you defined. For example:
// MyCppProject.cpp
// Adding a reference to an existing assembly using the project
// setting removes the need for the following line as it is added
// implicitly using the /FU compiler command-line option: but having
// it heres makes the example somewhat clearer
#using <MyVBButton.dll>
using namespace MyVBNamespace;
public ref class MyForm : Form
{
public:
// ...
private:
MyCustomButton^ button1;
};
nostra49
Dr Zombie
If you use the project properties to add a reference to the assembly then you should not need to add a #using (or add /AI to the cmd-line) as the project system will set everything up correctly. You only need #using and /AI if you want access the assembly manually - and I don't suggest doing this as the project system will not know about this relationship between the projects and hence they may not be kept correctly up to date.
tsharma
The easiest way is to bring up your C++ project properties page (I usually do this by right-clicking on the project and select properties). Click on "Common Properties" and then on "References" then click on "Add New Reference..." this will bring up a dialog. If your VB control and your C++ project are both part of the same solution then I would suggest that at this point you click on the "Browse" or "Recent" tabs and navigate and select the VB assembly. Remember to match debug to debug and release to release.
bowman
Add something like the following to the compiler command-line:
/AIC:\Myprojects\MyVBControls\debug
Shamrox