Reputation: 4544
I have two classes as follows
Public Class A_one 'This project does not have a dll generated even after a build. Any reason why ?
Public Structure struct
Dim xyz as String
Dim p as String
End Structure
Public Sub xyz(...)
ClassB_one_Obj = New ClassB_one_Obj(SampleStruct)
ClassB_one_Obj.send_struct(sampleStruct)
End Sub
Public Class B_one 'In a different project
Public Sub send_struct(ByVal sampleStruct As A_one.struct) 'Throwing error here **"Type A_one.struct not defined"**
Can anybody explain why i'm getting the error. Is it because I have not added the dll reference of class A_one in Class B_one ? I tried to add the reference dll of A_one , but was not able to find it either in the obj/bin folders . Can anybody point me to a work around ?
EDIT/UPDATE : Figured that the class A_one which is the main executable creates objects of Class B_one and that is the reason we can't create an object of class A_one in B_one, since there is a deadlock-like situation.
Is it true that we can't create an object of the main class ( start-up class ) from another class ?
Upvotes: 0
Views: 1088
Reputation: 4340
Yes, the error is because project B is not referencing project A, so it doesn't know anything about that type.
From withing Visual Studio, go to the properties of project B, References, Add. If project A is in the same solution as B, add it as as a Project/Solution reference, otherwise you can browse for the DLL. If you use the DLL method, you will have to ensure that the project type of project A is set to be a Class Library and that it has been successfully built. If its not set to be a Class Library project, it will most likely have built as an EXE file (you can add a reference to an EXE file as well, if you need project A to stay as a stand-alone executable).
Upvotes: 1