Click here to Skip to main content
13,150,344 members (30,571 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Friends,

I created a sample application in VC++ with two constructors....
class CFirst_ATL
    //Default constructor
    Num1 = 10;
    Num2 = 5;
    //Parameterized constructor
    CFirst_ATL(int val1,int val2)
        Num1 = val1;
        Num2 = val2;
	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 19:05pm
Updated 17-Apr-13 19:59pm
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?

rk_prabakar 18-Apr-13 1:24am
Class name is CFirst_ATL. I updated the class with declarations.
TusharKhairnar 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 18-Apr-13 2:38am
I tried this too... throws missing assembly reference library.
TusharKhairnar 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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2017
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