Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC++
Hi Friends,
 
I created a sample application in VC++ with two constructors....
class CFirst_ATL
{
public:
    //Default constructor
    CFirst_ATL()
    {
    Num1 = 10;
    Num2 = 5;
    }
 
    //Parameterized constructor
    CFirst_ATL(int val1,int val2)
    {
        Num1 = val1;
        Num2 = val2;
}
public:
	int Num1,Num2;
	STDMETHOD(AddNumbers)(LONG* ReturnVal);
	STDMETHOD(SubNumbers)(LONG* ReturnVal);
	STDMETHOD(MulNumbers)(LONG* ReturnVal);
	STDMETHOD(DivNumbers)(LONG* ReturnVal);
};
 
I referenced the dll to my c# application and works fine for default constructor.
I want to call parameterized constructor from my c# application for that I used this code
 
IFirst_ATL obj = new First_ATL(2,1);
 
Even after this, value is assigned with 10 and 5 only not 1 and 2.
Can anyone help me on this?
 
Thanks in advance.
Posted 17-Apr-13 20:05pm
Edited 17-Apr-13 20:59pm
v5
Comments
Sergey Alexandrovich Kryukov at 18-Apr-13 1:19am
   
The class name: First_ATL or CFirst_ATL? When you show not the real code you would paste but write it right on the page, any kinds of problems can happen. Don't you have both classes, slightly different?
 
Initializers in constructors have special syntax like ": Num1(val1)", but this is not yes a problem. Will you show the declaration of Num1, Num2?
 
—SA
rk_prabakar at 18-Apr-13 1:24am
   
Class name is CFirst_ATL. I updated the class with declarations.
TusharKhairnar at 18-Apr-13 2:22am
   
i may think here is problem
IFirst_ATL obj = new First_ATL(2,1);
your class name CFirst_Alt
IFirst_ATL obj = new CFirst_ATL(2,1);
try for this
rk_prabakar at 18-Apr-13 2:38am
   
I tried this too... throws missing assembly reference library.
TusharKhairnar at 18-Apr-13 3:04am
   
check your bin folder is that dll file is there. If that file available then check reference. Remove the current reference to that dll and make another reference.
rk_prabakar at 18-Apr-13 3:21am
   
I have both c# application and VC++ application in same solution so once i rebuild the application C# application automatically refers to VC++ updated dll.:-)
TusharKhairnar at 18-Apr-13 3:54am
   
it's OK but your Error means something like this. try to remove reference and add once again
rk_prabakar at 18-Apr-13 5:06am
   
I am able to debug the dll solution from c# application as well. There is no problem in adding reference I believe.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100