|
How can I use a .NET dll in a C++ application?
|
|
|
|
|
Just use the C++ in the .NET environment. Install the Visual Studio .Net and use the C++ over three
jamil abou khalil
MSN: jamilaboukhalil@hotmail.com
|
|
|
|
|
Hello
Sorry! You can't! .Net dlls are managed code. You know you can call unmanaged code by P/Invoke, but not vice versa. If there is a managed code that you want to use, maybe you could make it a service or a commandline console application, then you can communicate with it from your C++ program.
Regards
|
|
|
|
|
I've searched some documentation and I was able to do it.
The trick is to register the .Net dll as a COM server.
But to be able to register it as a COM server you must first have a tlb file of it.
This tlb file you can create with the visual studio tool tlbexp.exe.
From the command prompt:
tlbexp dotNET.dll /win32 /out:dotNET.tlb
Once you have the tlb file you can use regasm to register the .Net dll as a COM server. You will not be able to run regasm from the windows command prompt. You must launch the visual studio command prompt to do this.
In the visual studio command prompt type:
regasm dotNET.dll /tlb:dotNET.tlb
From this point you can use the classes and functions of the .Net dll is whatever language that understands COM.
Kind regards,
|
|
|
|
|
Truely I solute you. I really urge you to write an article about it in CodeProject with more details. Many people will miss this old post. I've allowed myself to bookmark this post for future referal. Really brilliant.
Regards
|
|
|
|
|
Hi all.
I have the following. A form with a splitcontainer, ie.. panel1 left & panel2 right. On the left panel I have a treeview, as the user selects an item from the treeview I want to display the appropriate form onto the right hand panel.
I tried the following, it compiles but fails at runtime.
splitcontainer.panel2.Containers.Add(new frmToDisplay);
Any help will be appreciated, thanx
He who laughs last is a bit on the slow side
|
|
|
|
|
try this
objfrm = new frmToDisplay();
objfrm.Parent = splitcontainer.panel2;
objfrm.show();
or
splitcontainer.panel2.Controls.Add(new frmToDisplay);
Hope that works fine for u
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Thanx for the quick reply.
Both examples compiles fine but I recieve the following error at runtime.
"Top level control can not be added to a control."
Not sure what it means or how to make the panel top level control
He who laughs last is a bit on the slow side
|
|
|
|
|
Dont use the second one
Tyr the first option
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Hi,
Try converting your form to a UserControl. It works better.
Do your best to be the best
|
|
|
|
|
Not sure if I did it the right way, tried it via casting. ie
Form form1 = new Form();
UserControl uctrl = new UserControl();
uctrl = (UserControl)form1;
But compilation fialed and I recieve the error - Cannot Convert Form to UserControl
He who laughs last is a bit on the slow side
|
|
|
|
|
to convert the form to usercontrol
just change the class derivation from Forms to UserControl.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Just to make sure I understand this correctly. You mean...
I must change the folloeing within the form that I try to load into the panel??
public class frmReportPrintSettings : System.Windows.Forms.Form
Change to
public class frmReportPrintSettings : System.Windows.Forms.UserControl
He who laughs last is a bit on the slow side
|
|
|
|
|
Yesssssss....
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
form is your form to be put in panel.
if(form != null)
{
form.ControlBox = false;
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.Dock = DockStyle.Fill;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.TopLevel = false;
panelTop.Controls.Add(form);
form.Show();
form.BringToFront();
}
else
{
panelTop.Controls.Clear();
}
|
|
|
|
|
|
Hai
i want to verify the com components which i am referencing are resgistered or not and if not they needs to be registered in a particular folder
Can i know the way
|
|
|
|
|
Hi!
A simple way would be to try to instantiate the COM object you intend to use. If this throws a COMException, the component usually simply isn't registered (yet).
But there is no way you can find out which folder a component has to be registered from, that completely depends on the component you want to use.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
When client deploys the application and Com components are not registered it throws the exception.
so that needs to checked and added as users wont have knowledge on registering the dlls.
|
|
|
|
|
Yes, if the components are not registered correctly, the exception I've mentioned will occurr.
But, as with all exceptions, you can catch them ("that needs to checked") and then register the dlls yourself (using Process.Start("regsvr32 -s comdll.dll"); ) if you know where they're located.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks for showing me the way
i will try
Thanks boss
|
|
|
|
|
How to write a javascript code for
a textbox that allows only digits and after decimal point it has to allow only two digits?
Thanks,
Hosanna
|
|
|
|
|
Wrong board! You're in the C# board not in the javascript board.
To answer your question, you could simply use a change event where you can then check by using, for example a regular expression.
|
|
|
|
|
hi all , i need to print my report in landscape when the user click on the print button(with out showing the preview dialog)...i tyr this with the following code but it still print in portraid... here is my code..
ReportDocument rd = New ReportDocument();
rd.Load("C:\Inetpub\wwwroot\test\CrystalReport3.rpt")
rd.SetDatabaseLogon("sa", "ssg")
rd.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
rd.PrintOptions.PrinterName = "printername"
rd.PrintToPrinter(1,False,0,0)
whats wrong with my code....plz help me to solve this issue...
ayyp
|
|
|
|
|
Hi,
Is it possible for an application to Dock to the top of the screen and be ontop of other windows. However I want other applications to not be under the form, but start/end where my application finishes.
Basically want the form to have the same importance as the windows taskbar...
Thanks
|
|
|
|